commit: r1599 - neon/trunk/src

joe at manyfish.co.uk joe at manyfish.co.uk
Tue Nov 4 15:49:35 EST 2008


Author: joe
Date: Tue Nov  4 12:49:35 2008
New Revision: 1599

Modified:
   neon/trunk/src/ne_socket.c

Log:
* src/ne_socket.c (ne_sock_connect): Use SOCK_CLOEXEC in place of
  setting the O_CLOEXEC flag, where available.


Modified: neon/trunk/src/ne_socket.c
==============================================================================
--- neon/trunk/src/ne_socket.c	(original)
+++ neon/trunk/src/ne_socket.c	Tue Nov  4 12:49:35 2008
@@ -1281,6 +1281,11 @@
     }
 }
 
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 0
+#define USE_CLOEXEC
+#endif
+
 int ne_sock_connect(ne_socket *sock,
                     const ne_inet_addr *addr, unsigned int port)
 {
@@ -1288,7 +1293,7 @@
 
     /* use SOCK_STREAM rather than ai_socktype: some getaddrinfo
      * implementations do not set ai_socktype, e.g. RHL6.2. */
-    fd = socket(ia_family(addr), SOCK_STREAM, ia_proto(addr));
+    fd = socket(ia_family(addr), SOCK_STREAM | SOCK_CLOEXEC, ia_proto(addr));
     if (fd < 0) {
         set_strerror(sock, ne_errno);
 	return -1;
@@ -1303,7 +1308,7 @@
 #endif
    
 #if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) \
-    && defined(FD_CLOEXEC)
+  && defined(FD_CLOEXEC) && defined(USE_CLOEXEC)
     /* Set the FD_CLOEXEC bit for the new fd. */
     if ((ret = fcntl(fd, F_GETFD)) >= 0) {
         fcntl(fd, F_SETFD, ret | FD_CLOEXEC);




More information about the neon-commits mailing list