]> granicus.if.org Git - apache/commitdiff
handle a TCP connection reset between the time we accept the connection
authorJeff Trawick <trawick@apache.org>
Thu, 1 Feb 2001 17:21:49 +0000 (17:21 +0000)
committerJeff Trawick <trawick@apache.org>
Thu, 1 Feb 2001 17:21:49 +0000 (17:21 +0000)
and when apr_get_sockaddr() does getsockname() or getpeername()

this change will be rolled into the other MPMs later

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87947 13f79535-47bb-0310-9956-ffa450edef68

server/connection.c
server/mpm/prefork/prefork.c

index 5c9f50bf01a08d9a199701036f17822d5c51cdb4..6287fa2177b815a252a73725875be46b288c2bbf 100644 (file)
@@ -67,6 +67,7 @@
 #include "mpm_status.h"
 #include "http_config.h"
 #include "http_vhost.h"
+#include "http_log.h"
 #include "util_filter.h"
 
 #ifdef HAVE_NETINET_IN_H
@@ -270,6 +271,7 @@ conn_rec *ap_new_connection(apr_pool_t *p, server_rec *server,
                             apr_socket_t *inout, long id)
 {
     conn_rec *conn = (conn_rec *) apr_pcalloc(p, sizeof(conn_rec));
+    apr_status_t rv;
 
     /* Got a connection structure, so initialize what fields we can
      * (the rest are zeroed out by pcalloc).
@@ -279,9 +281,21 @@ conn_rec *ap_new_connection(apr_pool_t *p, server_rec *server,
     conn->notes = apr_make_table(p, 5);
 
     conn->pool = p;
-    apr_get_sockaddr(&conn->local_addr, APR_LOCAL, inout);
+    if ((rv = apr_get_sockaddr(&conn->local_addr, APR_LOCAL, inout)) 
+        != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
+                     "apr_get_sockaddr(APR_LOCAL)");
+        apr_close_socket(inout);
+        return NULL;
+    }
     apr_get_ipaddr(&conn->local_ip, conn->local_addr);
-    apr_get_sockaddr(&conn->remote_addr, APR_REMOTE, inout);
+    if ((rv = apr_get_sockaddr(&conn->remote_addr, APR_REMOTE, inout))
+        != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
+                     "apr_get_sockaddr(APR_REMOTE)");
+        apr_close_socket(inout);
+        return NULL;
+    }
     apr_get_ipaddr(&conn->remote_ip, conn->remote_addr);
     conn->base_server = server;
     conn->client_socket = inout;
index 098d67d8a1e7bc3feb78db159c84a68f2b8f788f..7db36c0b28ee8da1ef9b0c00e474aeaf216f9e50 100644 (file)
@@ -1048,9 +1048,10 @@ static void child_main(int child_num_arg)
 
        current_conn = ap_new_connection(ptrans, ap_server_conf, csd, 
                                          my_child_num);
-
-       ap_process_connection(current_conn);
-        ap_lingering_close(current_conn);
+        if (current_conn) {
+            ap_process_connection(current_conn);
+            ap_lingering_close(current_conn);
+        }
     }
     clean_child_exit(0);
 }