summaryrefslogtreecommitdiff
path: root/zookeeper-client
diff options
context:
space:
mode:
authorChristopher Tubbs <ctubbsii@apache.org>2020-10-22 07:50:53 +0000
committerMate Szalay-Beko <symat@apache.org>2020-10-22 07:50:53 +0000
commitffcea5b291c5a26fd8dff66a9752b80f559394e1 (patch)
treeef446101ad68caf3ce6e2326ae9d8c23d6bdebdc /zookeeper-client
parentf06db8c91becf812c539747a406ba84635b2c1ac (diff)
downloadzookeeper-ffcea5b291c5a26fd8dff66a9752b80f559394e1.tar.gz
ZOOKEEPER-3983: Avoid mocking unix domain sockets
This fixes issues with the C client tests, causing them to hang if certain nameservices are in use (such as SSS), which use UNIX domain sockets for getting the `getlogin()` and `getpwuid_r()` This change makes the mocking of sockets less aggressive, since the tests do not need to mock `AF_UNIX` socket types. Author: Christopher Tubbs <ctubbsii@apache.org> Reviewers: Damien Diederen <dd@crosstwine.com>, Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org> Closes #1514 from ctubbsii/ZOOKEEPER-3983-no-mock-unix-sockets
Diffstat (limited to 'zookeeper-client')
-rw-r--r--zookeeper-client/zookeeper-client-c/tests/LibCMocks.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/zookeeper-client/zookeeper-client-c/tests/LibCMocks.cc b/zookeeper-client/zookeeper-client-c/tests/LibCMocks.cc
index 870a554ca..8a46ee54d 100644
--- a/zookeeper-client/zookeeper-client-c/tests/LibCMocks.cc
+++ b/zookeeper-client/zookeeper-client-c/tests/LibCMocks.cc
@@ -259,7 +259,12 @@ int setsockopt(int s,int level,int optname,const void *optval,socklen_t optlen){
return Mock_socket::mock_->callSet(s,level,optname,optval,optlen);
}
int connect(int s,const struct sockaddr *addr,socklen_t len){
+#ifdef AF_UNIX
+ /* don't mock UNIX domain sockets */
+ if (!Mock_socket::mock_ || addr->sa_family == AF_UNIX)
+#else
if (!Mock_socket::mock_)
+#endif
return LIBC_SYMBOLS.connect(s,addr,len);
return Mock_socket::mock_->callConnect(s,addr,len);
}