diff options
Diffstat (limited to 'lib/cpp/src/thrift/transport/TServerSocket.cpp')
-rw-r--r-- | lib/cpp/src/thrift/transport/TServerSocket.cpp | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp index 6b7652560..5c58bda05 100644 --- a/lib/cpp/src/thrift/transport/TServerSocket.cpp +++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp @@ -48,6 +48,7 @@ #include <thrift/transport/TServerSocket.h> #include <thrift/transport/TSocket.h> #include <thrift/transport/TSocketUtils.h> +#include <thrift/transport/SocketCommon.h> #ifndef AF_LOCAL #define AF_LOCAL AF_UNIX @@ -397,32 +398,14 @@ void TServerSocket::listen() { _setup_sockopts(); _setup_unixdomain_sockopts(); +/* + * TODO: seems that windows now support unix sockets, + * see: https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ + */ #ifndef _WIN32 - size_t len = path_.size() + 1; - if (len > sizeof(((sockaddr_un*)nullptr)->sun_path)) { - errno_copy = THRIFT_GET_SOCKET_ERROR; - GlobalOutput.perror("TSocket::listen() Unix Domain socket path too long", errno_copy); - throw TTransportException(TTransportException::NOT_OPEN, - "Unix Domain socket path too long", - errno_copy); - } struct sockaddr_un address; - address.sun_family = AF_UNIX; - memcpy(address.sun_path, path_.c_str(), len); - - auto structlen = static_cast<socklen_t>(sizeof(address)); - - if (!address.sun_path[0]) { // abstract namespace socket -#ifdef __linux__ - // sun_path is not null-terminated in this case and structlen determines its length - structlen -= sizeof(address.sun_path) - len; -#else - GlobalOutput.perror("TSocket::open() Abstract Namespace Domain sockets only supported on linux: ", -99); - throw TTransportException(TTransportException::NOT_OPEN, - " Abstract Namespace Domain socket path not supported"); -#endif - } + socklen_t structlen = fillUnixSocketAddr(address, path_); do { if (0 == ::bind(serverSocket_, (struct sockaddr*)&address, structlen)) { |