apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r442135 - /apr/apr/trunk/network_io/unix/sockets.c
Date Mon, 11 Sep 2006 09:30:22 GMT
Author: mturk
Date: Mon Sep 11 02:30:21 2006
New Revision: 442135

URL: http://svn.apache.org/viewvc?view=rev&rev=442135
Log:
Do not allocate new socket if accept fails.

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?view=diff&rev=442135&r1=442134&r2=442135
==============================================================================
--- apr/apr/trunk/network_io/unix/sockets.c (original)
+++ apr/apr/trunk/network_io/unix/sockets.c Mon Sep 11 02:30:21 2006
@@ -176,29 +176,34 @@
 apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock,
                                apr_pool_t *connection_context)
 {
-    alloc_socket(new, connection_context);
-    set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM, sock->protocol);
+    int s;
+    apr_sockaddr_t sa;
 
-#ifndef HAVE_POLL
-    (*new)->connected = 1;
-#endif
-    (*new)->timeout = -1;
-    
-    (*new)->socketdes = accept(sock->socketdes, 
-                               (struct sockaddr *)&(*new)->remote_addr->sa,
-                               &(*new)->remote_addr->salen);
+    apr_sockaddr_vars_set(&sa, sock->local_addr->sa.sin.sin_family, 0);
+    sa.pool = connection_context;
+    s = accept(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen);
 
-    if ((*new)->socketdes < 0) {
+    if (s < 0) {
         return errno;
     }
 #ifdef TPF
-    if ((*new)->socketdes == 0) { 
+    if (s == 0) { 
         /* 0 is an invalid socket for TPF */
         return APR_EINTR;
     }
 #endif
+    alloc_socket(new, connection_context);
+    set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM, sock->protocol);
+
+#ifndef HAVE_POLL
+    (*new)->connected = 1;
+#endif
+    (*new)->timeout = -1;
 
     (*new)->remote_addr_unknown = 0;
+
+    (*new)->socketdes = s;
+    *(*new)->remote_addr = sa;
 
     *(*new)->local_addr = *sock->local_addr;
 



Mime
View raw message