apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1082963 - /apr/apr/trunk/network_io/unix/sockets.c
Date Fri, 18 Mar 2011 16:29:28 GMT
Author: trawick
Date: Fri Mar 18 16:29:27 2011
New Revision: 1082963

URL: http://svn.apache.org/viewvc?rev=1082963&view=rev
Log:
apr_socket_create/accept: clean up socket descriptor on
some error paths which happen before the cleanup is registered

Modified:
    apr/apr/trunk/network_io/unix/sockets.c

Modified: apr/apr/trunk/network_io/unix/sockets.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/sockets.c?rev=1082963&r1=1082962&r2=1082963&view=diff
==============================================================================
--- apr/apr/trunk/network_io/unix/sockets.c (original)
+++ apr/apr/trunk/network_io/unix/sockets.c Fri Mar 18 16:29:27 2011
@@ -177,10 +177,14 @@ apr_status_t apr_socket_create(apr_socke
         int flags;
 
         if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
+            close((*new)->socketdes);
+            (*new)->socketdes = -1;
             return errno;
 
         flags |= FD_CLOEXEC;
         if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
+            close((*new)->socketdes);
+            (*new)->socketdes = -1;
             return errno;
     }
 #endif
@@ -339,12 +343,18 @@ apr_status_t apr_socket_accept(apr_socke
     {
         int flags;
 
-        if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
+        if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) {
+            close((*new)->socketdes);
+            (*new)->socketdes = -1;
             return errno;
+        }
 
         flags |= FD_CLOEXEC;
-        if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
+        if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) {
+            close((*new)->socketdes);
+            (*new)->socketdes = -1;
             return errno;
+        }
     }
 #endif
 



Mime
View raw message