]> granicus.if.org Git - apache/commitdiff
Create new function, ap_lingering_close(), which will explicitly do a lingering close
authorBill Stoddard <stoddard@apache.org>
Thu, 11 May 2000 21:17:00 +0000 (21:17 +0000)
committerBill Stoddard <stoddard@apache.org>
Thu, 11 May 2000 21:17:00 +0000 (21:17 +0000)
if USE_SO_LINGER is not defined. Move responsibility for closing connections out
of http_connection.c and into the MPMs.

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

server/connection.c
server/mpm/dexter/dexter.c
server/mpm/mpmt_beos/mpmt_beos.c
server/mpm/mpmt_pthread/mpmt_pthread.c
server/mpm/prefork/prefork.c
server/mpm/spmt_os2/spmt_os2.c
server/mpm/winnt/mpm_winnt.c

index 09bdc4861be4ee68eb9867305c952e93ea8c0664..1967107c5a9af9a61e2027a115214aec789c1d50 100644 (file)
@@ -121,8 +121,6 @@ static void sock_enable_linger(int s)
 #define sock_enable_linger(s)  /* NOOP */
 #endif /* USE_SO_LINGER */
 
-#ifndef NO_LINGCLOSE
-
 /* we now proceed to read from the client until we get EOF, or until
  * MAX_SECS_TO_LINGER has passed.  the reasons for doing this are
  * documented in a draft:
@@ -134,7 +132,7 @@ static void sock_enable_linger(int s)
  * all the response data has been sent to the client.
  */
 
-static void lingering_close(conn_rec *c)
+void ap_lingering_close(conn_rec *c)
 {
     char dummybuf[512];
     ap_time_t start;
@@ -142,6 +140,22 @@ static void lingering_close(conn_rec *c)
     ap_status_t rc;
     int timeout;
 
+#ifdef NO_LINGCLOSE
+    ap_bclose(c->client);      /* just close it */
+    return;
+#endif
+
+    /* Close the connection, being careful to send out whatever is still
+     * in our buffers.  If possible, try to avoid a hard close until the
+     * client has ACKed our FIN and/or has stopped sending us data.
+     */
+
+    if (c->aborted || !(c->client)) {
+       ap_bsetflag(c->client, B_EOUT, 1);
+       ap_bclose(c->client);
+        return;
+    }
+
     /* Send any leftover data to the client, but never try to again */
 
     if (ap_bflush(c->client) != APR_SUCCESS) {
@@ -182,8 +196,6 @@ static void lingering_close(conn_rec *c)
     ap_bclose(c->client);
 }
 
-#endif /* ndef NO_LINGCLOSE */
-
 CORE_EXPORT(void) ap_process_connection(conn_rec *c)
 {
     ap_update_vhost_given_ip(c);
@@ -192,26 +204,6 @@ CORE_EXPORT(void) ap_process_connection(conn_rec *c)
 
     ap_run_process_connection(c);
 
-    /*
-     * Close the connection, being careful to send out whatever is still
-     * in our buffers.  If possible, try to avoid a hard close until the
-     * client has ACKed our FIN and/or has stopped sending us data.
-     */
-
-#ifdef NO_LINGCLOSE
-    ap_bclose(c->client);      /* just close it */
-#else
-    if (!c->aborted
-       && c->client
-       /* && (c->client->fd >= 0) */ ) {
-
-       lingering_close(c);
-    }
-    else {
-       ap_bsetflag(c->client, B_EOUT, 1);
-       ap_bclose(c->client);
-    }
-#endif
 }
 
 int ap_process_http_connection(conn_rec *c)
index fa57081da411f2266df64a6ec229c875346bce32..ff4387eb2e220f4b0393077dbeb18fb0cce1f861 100644 (file)
@@ -632,6 +632,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id)
                                          conn_id);
 
     ap_process_connection(current_conn);
+    ap_lingering_close(current_conn);
 }
 
 static void *worker_thread(void *);
index 5556a37fab83a2a24b41bd6fa87222d31896d9b3..260702995926344542135ba386b41dc8e2e3e914 100644 (file)
@@ -512,6 +512,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num, in
                                          conn_id);
 
     ap_process_connection(current_conn);
+    ap_lingering_close(current_conn);
 }
 
 static int32 worker_thread(void * dummy)
index e78d354a0bba50a98d9a1ee4ff6a8649f07350b4..9764c2e6576f1e0ab220912e43a910f1ba2387b9 100644 (file)
@@ -634,6 +634,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num, in
                                          conn_id);
 
     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 a2b4971862b8bea79162bf9967d9acb5baa5b5df..237035b659e3fb129f2de39dac7b60563a4ed700 100644 (file)
@@ -1694,6 +1694,7 @@ static void child_main(int child_num_arg)
                                         my_child_num);
 
        ap_process_connection(current_conn);
+        ap_lingering_close(current_conn);
     }
 }
 
index bf85505179952cfa9231934deb5389596ff8d880..2d4218e1209394749ff9c93f878bb1942330eccf 100644 (file)
@@ -1028,6 +1028,7 @@ static void child_main(void *child_num_arg)
                                              THREAD_GLOBAL(child_num));
 
        ap_process_connection(current_conn);
+        ap_lingering_close(current_conn);
     }
 
     clean_child_exit(0);
index dfa2d6414bb174e06dca0a8236257b737c2dd91e..f937c85bead0627042f92aa4536754949414c53e 100644 (file)
@@ -1062,6 +1062,7 @@ static void worker_main(int child_num)
                                          child_num);
 
         ap_process_connection(current_conn);
+        ap_lingering_close(current_conn);
     }
 
     ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf,