]> granicus.if.org Git - apache/commitdiff
ap_new_connection() returns NULL if an error occurred (prefork MPM
authorJeff Trawick <trawick@apache.org>
Mon, 5 Feb 2001 15:04:32 +0000 (15:04 +0000)
committerJeff Trawick <trawick@apache.org>
Mon, 5 Feb 2001 15:04:32 +0000 (15:04 +0000)
and ap_new_connection() were changed last week)

I have skipped putting the change into WinNT MPM and mod_proxy.  I
left a note in the mod_proxy code; for the NT MPM I think I can talk
somebody into doing the right thing for me.

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

CHANGES
include/http_connection.h
modules/proxy/proxy_http.c
server/mpm/beos/beos.c
server/mpm/dexter/dexter.c
server/mpm/experimental/perchild/perchild.c
server/mpm/mpmt_beos/mpmt_beos.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/perchild/perchild.c
server/mpm/spmt_os2/spmt_os2.c

diff --git a/CHANGES b/CHANGES
index 87bdb535018f98883df0ac391dd73d80fb9c3326..674fe385afb4e83ec8c8cc79fcef467ede795e49 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Changes with Apache 2.0b1
 
+  *) ap_new_connection() closes the socket and returns NULL if a socket
+     call fails.  Usually this is due to a connection which has been 
+     reset.  [Jeff Trawick]
+
   *) Move the Apache version information out of httpd.h and into release.h.
      This is in preparation for the first tag with the new tag and release
      system.  [Ryan Bloom]
index 82c3135e6e29af3d2f271d6faa1404770fb22e43..5bff6bc7295e0c3e59934d244492ae1119c871bd 100644 (file)
@@ -73,6 +73,7 @@ extern "C" {
  * @param server The server to create the connection for
  * @param inout The socket to use for all communication with the client
  * @param id ID of this connection; unique at any point in time.
+ * @return new conn_rec, or NULL if the connection has already been reset
  */
 conn_rec *ap_new_connection(apr_pool_t *p, server_rec *server, 
                             apr_socket_t *inout, long id);
index 3e61f2e7b3dbcd1a88b582af7c50cbc15ca973cb..68e9837b6a0654b85a8ad5e659cd0db7b6fc2116 100644 (file)
@@ -277,6 +277,12 @@ int ap_proxy_http_handler(request_rec *r, char *url,
     }
 
     origin = ap_new_connection(r->pool, r->server, sock, 0);
+    if (!origin) {
+        /* the peer reset the connection already; ap_new_connection() 
+         * closed the socket */
+        /* XXX somebody that knows what they're doing add an error path */
+    }
+
     ap_add_output_filter("CORE", NULL, NULL, origin);
 
     clear_connection(r->pool, r->headers_in);  /* Strip connection-based headers */
index 761e5ab14ac215939422df7d3f2b3f09e705127b..ff7361bc93eb3c73ae1e6af2a91f102b46c11edc 100644 (file)
@@ -317,9 +317,10 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num)
     }
     
     current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id);
-
-    ap_process_connection(current_conn);
-    ap_lingering_close(current_conn);
+    if (current_conn) {
+        ap_process_connection(current_conn);
+        ap_lingering_close(current_conn);
+    }
 }
 
 static int32 worker_thread(void * dummy)
index 7f198e9751d77160c453ccb5d44e6bad12e50994..8cd3d2c717094fbde6b1d197eb523eb2d078ba93 100644 (file)
@@ -419,9 +419,10 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
                                   SERVER_BUSY_READ, (request_rec *) NULL);
 
     current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id);
-
-    ap_process_connection(current_conn);
-    ap_lingering_close(current_conn);
+    if (current_conn) {
+        ap_process_connection(current_conn);
+        ap_lingering_close(current_conn);
+    }
 }
 
 static void *worker_thread(void *);
index 10932bc8e032f74e78c565082269ab53ca12a08e..899e84429ae8b0c89d9738e197c9d4b47e04a310 100644 (file)
@@ -456,9 +456,10 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
     }
 
     current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id);
-
-    ap_process_connection(current_conn);
-    ap_lingering_close(current_conn);
+    if (current_conn) {
+        ap_process_connection(current_conn);
+        ap_lingering_close(current_conn);
+    }
 }
 
 static void *worker_thread(void *);
index 616cdb7d5686dd2dd6be5cb00cb000b9bac61a5c..c758bd1feff2630c210fc83d7a9e87491076f8da 100644 (file)
@@ -300,9 +300,10 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num,
     int csd;
 
     current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id);
-
-    ap_process_connection(current_conn);
-    ap_lingering_close(current_conn);
+    if (current_conn) {
+        ap_process_connection(current_conn);
+        ap_lingering_close(current_conn);
+    }
 }
 
 static int32 worker_thread(void * dummy)
index 368cb1b46785df32617358f267aa04c7f0c4ab04..5f707e46f41056893c28550d8bc17862c413cb18 100644 (file)
@@ -410,9 +410,10 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num,
                                  SERVER_BUSY_READ, (request_rec *) NULL);
 
     current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id);
-
-    ap_process_connection(current_conn);
-    ap_lingering_close(current_conn);
+    if (current_conn) {
+        ap_process_connection(current_conn);
+        ap_lingering_close(current_conn);
+    }
 }
 /* Sets workers_may_exit if we received a character on the pipe_of_death */
 static void check_pipe_of_death(void)
index 10932bc8e032f74e78c565082269ab53ca12a08e..899e84429ae8b0c89d9738e197c9d4b47e04a310 100644 (file)
@@ -456,9 +456,10 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id)
     }
 
     current_conn = ap_new_connection(p, ap_server_conf, sock, conn_id);
-
-    ap_process_connection(current_conn);
-    ap_lingering_close(current_conn);
+    if (current_conn) {
+        ap_process_connection(current_conn);
+        ap_lingering_close(current_conn);
+    }
 }
 
 static void *worker_thread(void *);
index f8a2983e2f5a04b97b2a8bf308782c3db1759fea..0ed25a025e1c96a6027f774174a2e8116323db42 100644 (file)
@@ -940,9 +940,10 @@ static void child_main(void *child_num_arg)
 
        current_conn = ap_new_connection(ptrans, ap_server_conf, csd,
                                          THREAD_GLOBAL(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);