summaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorIsaac Boukris <iboukris@gmail.com>2017-01-09 00:51:08 +0200
committerPeter Wu <peter@lekensteyn.nl>2017-01-13 16:25:20 +0100
commit1d786faee1046ff90e71252aeef4a997c3bf0d8d (patch)
tree325ebddb13f12be61a28062c2f06980e2a34754a /lib/url.c
parenta7c73ae309c03bd84b28659421ac613e503565ce (diff)
downloadcurl-1d786faee1046ff90e71252aeef4a997c3bf0d8d.tar.gz
unix_socket: add support for abstract unix domain socket
In addition to unix domain sockets, Linux also supports an abstract namespace which is independent of the filesystem. In order to support it, add new CURLOPT_ABSTRACT_UNIX_SOCKET option which uses the same storage as CURLOPT_UNIX_SOCKET_PATH internally, along with a flag to specify abstract socket. On non-supporting platforms, the abstract address will be interpreted as an empty string and fail gracefully. Also add new --abstract-unix-socket tool parameter. Signed-off-by: Isaac Boukris <iboukris@gmail.com> Reported-by: Chungtsun Li (typeless) Reviewed-by: Daniel Stenberg Reviewed-by: Peter Wu Closes #1197 Fixes #1061
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/url.c b/lib/url.c
index 074289ed4..edae1e3f3 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2814,6 +2814,12 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
#ifdef USE_UNIX_SOCKETS
case CURLOPT_UNIX_SOCKET_PATH:
+ data->set.abstract_unix_socket = FALSE;
+ result = setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_ABSTRACT_UNIX_SOCKET:
+ data->set.abstract_unix_socket = TRUE;
result = setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
va_arg(param, char *));
break;
@@ -3523,6 +3529,8 @@ ConnectionExists(struct Curl_easy *data,
continue;
if(strcmp(needle->unix_domain_socket, check->unix_domain_socket))
continue;
+ if(needle->abstract_unix_socket != check->abstract_unix_socket)
+ continue;
}
else if(check->unix_domain_socket)
continue;
@@ -5863,8 +5871,9 @@ static CURLcode resolve_server(struct Curl_easy *data,
if(!hostaddr)
result = CURLE_OUT_OF_MEMORY;
else {
- int longpath=0;
- hostaddr->addr = Curl_unix2addr(path, &longpath);
+ bool longpath = FALSE;
+ hostaddr->addr = Curl_unix2addr(path, &longpath,
+ conn->abstract_unix_socket);
if(hostaddr->addr)
hostaddr->inuse++;
else {
@@ -6273,6 +6282,7 @@ static CURLcode create_conn(struct Curl_easy *data,
result = CURLE_OUT_OF_MEMORY;
goto out;
}
+ conn->abstract_unix_socket = data->set.abstract_unix_socket;
}
#endif