commit: r1600 - neon/branches/0.28.x/src

joe at manyfish.co.uk joe at manyfish.co.uk
Tue Nov 4 15:56:04 EST 2008


Author: joe
Date: Tue Nov  4 12:56:04 2008
New Revision: 1600

Modified:
   neon/branches/0.28.x/src/ne_socket.c

Log:
Merge r1599 from trunk:

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


Modified: neon/branches/0.28.x/src/ne_socket.c
==============================================================================
--- neon/branches/0.28.x/src/ne_socket.c	(original)
+++ neon/branches/0.28.x/src/ne_socket.c	Tue Nov  4 12:56:04 2008
@@ -1191,6 +1191,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)
 {
@@ -1198,7 +1203,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;
@@ -1213,7 +1218,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