]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
Refresh of fork-fix
authorSean Hefty <sean.hefty@intel.com>
Thu, 23 Aug 2012 18:31:58 +0000 (11:31 -0700)
committerSean Hefty <sean.hefty@intel.com>
Thu, 23 Aug 2012 18:31:58 +0000 (11:31 -0700)
src/preload.c

index 0645f6ddb780db03d8ab44bee231021c33c4a9ed..4ba38f5f28c75d7e592d71da1aa9a2539f075a94 100644 (file)
@@ -412,20 +412,21 @@ int socket(int domain, int type, int protocol)
        if (index < 0)
                return index;
 
+       if (fork_support && (domain == PF_INET || domain == PF_INET6) &&
+           (type == SOCK_STREAM) && (!protocol || protocol == IPPROTO_TCP)) {
+               ret = real.socket(domain, type, protocol);
+               if (ret < 0)
+                       return ret;
+               fd_store(index, ret, fd_normal, fd_fork);
+               return index;
+       }
+
        recursive = 1;
        ret = rsocket(domain, type, protocol);
        recursive = 0;
        if (ret >= 0) {
-               if (fork_support) {
-                       rclose(ret);
-                       ret = real.socket(domain, type, protocol);
-                       if (ret < 0)
-                               return ret;
-                       fd_store(index, ret, fd_normal, fd_fork);
-               } else {
-                       fd_store(index, ret, fd_rsocket, fd_ready);
-                       set_rsocket_options(ret);
-               }
+               fd_store(index, ret, fd_rsocket, fd_ready);
+               set_rsocket_options(ret);
                return index;
        }
        fd_close(index, &ret);