You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by sy...@apache.org on 2020/10/22 07:51:44 UTC

[zookeeper] branch master updated: ZOOKEEPER-3983: Avoid mocking unix domain sockets

This is an automated email from the ASF dual-hosted git repository.

symat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new ffcea5b  ZOOKEEPER-3983: Avoid mocking unix domain sockets
ffcea5b is described below

commit ffcea5b291c5a26fd8dff66a9752b80f559394e1
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Thu Oct 22 07:50:53 2020 +0000

    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 <ct...@apache.org>
    
    Reviewers: Damien Diederen <dd...@crosstwine.com>, Enrico Olivelli <eo...@apache.org>, Mate Szalay-Beko <sy...@apache.org>
    
    Closes #1514 from ctubbsii/ZOOKEEPER-3983-no-mock-unix-sockets
---
 zookeeper-client/zookeeper-client-c/tests/LibCMocks.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/zookeeper-client/zookeeper-client-c/tests/LibCMocks.cc b/zookeeper-client/zookeeper-client-c/tests/LibCMocks.cc
index 870a554..8a46ee5 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);
 }