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

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


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

commit bd1c7b64b26cb49410e026d0e6a72b8650238bee
Author: Christopher Tubbs <[email protected]>
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 <[email protected]>
    
    Reviewers: Damien Diederen <[email protected]>, Enrico Olivelli 
<[email protected]>, Mate Szalay-Beko <[email protected]>
    
    Closes #1514 from ctubbsii/ZOOKEEPER-3983-no-mock-unix-sockets
    
    (cherry picked from commit ffcea5b291c5a26fd8dff66a9752b80f559394e1)
    Signed-off-by: Mate Szalay-Beko <[email protected]>
---
 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);
 }

Reply via email to