From: Ryan Bloom Date: Sat, 10 Nov 2001 18:26:30 +0000 (+0000) Subject: Remove ap_lingering_close from all of the MPMs. This is now done as X-Git-Tag: 2.0.29~204 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13cf9521f5a1b2746dde82c3082ea41109214c9f;p=apache Remove ap_lingering_close from all of the MPMs. This is now done as a cleanup registered with the connection_pool. I have also turned ap_lingering_close into a static function, because it is only used in connection.c. This is the next step to consolidating all of the socket function calls. ap_lingering_close will only be added if the core is dealing with a standard socket. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91832 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/http_connection.h b/include/http_connection.h index 37fcba7fab..4abad5ce08 100644 --- a/include/http_connection.h +++ b/include/http_connection.h @@ -88,22 +88,6 @@ AP_CORE_DECLARE(void) ap_process_connection(conn_rec *); AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c); -/** - * This function is responsible for the following cases: - *
- * 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:
- *
- * http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-connection-00.txt
- *
- * in a nutshell -- if we don't make this effort we risk causing
- * TCP RST packets to be sent which can tear down a connection before
- * all the response data has been sent to the client.
- * 
- * @param c The connection we are closing - */ -void ap_lingering_close(conn_rec *); #endif /* Hooks */ diff --git a/server/connection.c b/server/connection.c index 5356c7bd47..eba68b6510 100644 --- a/server/connection.c +++ b/server/connection.c @@ -149,13 +149,14 @@ AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c) * all the response data has been sent to the client. */ #define SECONDS_TO_LINGER 2 -void ap_lingering_close(conn_rec *c) +static apr_status_t ap_lingering_close(void *dummy) { char dummybuf[512]; apr_size_t nbytes = sizeof(dummybuf); apr_status_t rc; apr_int32_t timeout; apr_int32_t total_linger_time = 0; + conn_rec *c = dummy; ap_update_child_status(AP_CHILD_THREAD_FROM_ID(c->id), SERVER_CLOSING, NULL); @@ -175,7 +176,7 @@ void ap_lingering_close(conn_rec *c) if (c->aborted) { apr_socket_close(c->client_socket); - return; + return APR_SUCCESS; } /* Shut down the socket for write, which will send a FIN @@ -185,7 +186,7 @@ void ap_lingering_close(conn_rec *c) if (apr_shutdown(c->client_socket, APR_SHUTDOWN_WRITE) != APR_SUCCESS || c->aborted) { apr_socket_close(c->client_socket); - return; + return APR_SUCCESS; } /* Read all data from the peer until we reach "end-of-file" (FIN @@ -208,6 +209,7 @@ void ap_lingering_close(conn_rec *c) } apr_socket_close(c->client_socket); + return APR_SUCCESS; } AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c) @@ -262,5 +264,7 @@ AP_CORE_DECLARE(conn_rec *)ap_new_connection(apr_pool_t *p, server_rec *server, conn->id = id; + apr_pool_cleanup_register(p, conn, ap_lingering_close, apr_pool_cleanup_null); + return conn; } diff --git a/server/mpm/beos/beos.c b/server/mpm/beos/beos.c index a872b7654f..7e43f56ef6 100644 --- a/server/mpm/beos/beos.c +++ b/server/mpm/beos/beos.c @@ -316,7 +316,6 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num) if (current_conn) { ap_process_connection(current_conn); - ap_lingering_close(current_conn); } } diff --git a/server/mpm/experimental/perchild/perchild.c b/server/mpm/experimental/perchild/perchild.c index f2cb943ee7..2a8cbe6ba4 100644 --- a/server/mpm/experimental/perchild/perchild.c +++ b/server/mpm/experimental/perchild/perchild.c @@ -505,7 +505,6 @@ 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); if (current_conn) { ap_process_connection(current_conn); - ap_lingering_close(current_conn); } } diff --git a/server/mpm/mpmt_os2/mpmt_os2_child.c b/server/mpm/mpmt_os2/mpmt_os2_child.c index e9cfcecbe8..2694a75091 100644 --- a/server/mpm/mpmt_os2/mpmt_os2_child.c +++ b/server/mpm/mpmt_os2/mpmt_os2_child.c @@ -411,7 +411,6 @@ static void worker_main(void *vpArg) if (current_conn) { ap_process_connection(current_conn); - ap_lingering_close(current_conn); } apr_pool_destroy(pconn); diff --git a/server/mpm/netware/mpm_netware.c b/server/mpm/netware/mpm_netware.c index d91237d29c..705948dbce 100644 --- a/server/mpm/netware/mpm_netware.c +++ b/server/mpm/netware/mpm_netware.c @@ -509,7 +509,6 @@ got_listener: current_conn = ap_new_connection(ptrans, ap_server_conf, csd, my_worker_num); if (current_conn) { ap_process_connection(current_conn); - ap_lingering_close(current_conn); } } diff --git a/server/mpm/perchild/perchild.c b/server/mpm/perchild/perchild.c index f2cb943ee7..2a8cbe6ba4 100644 --- a/server/mpm/perchild/perchild.c +++ b/server/mpm/perchild/perchild.c @@ -505,7 +505,6 @@ 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); if (current_conn) { ap_process_connection(current_conn); - ap_lingering_close(current_conn); } } diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 3ae850b7ef..656b0cabf3 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -792,7 +792,6 @@ static void child_main(int child_num_arg) my_child_num); if (current_conn) { ap_process_connection(current_conn); - ap_lingering_close(current_conn); } /* Check the pod after processing a connection so that we'll go away diff --git a/server/mpm/spmt_os2/spmt_os2.c b/server/mpm/spmt_os2/spmt_os2.c index 3deba5a6b4..8a99733d85 100644 --- a/server/mpm/spmt_os2/spmt_os2.c +++ b/server/mpm/spmt_os2/spmt_os2.c @@ -685,7 +685,6 @@ static void thread_main(void *thread_num_arg) if (current_conn) { ap_process_connection(current_conn); - ap_lingering_close(current_conn); } } diff --git a/server/mpm/threaded/threaded.c b/server/mpm/threaded/threaded.c index 7818daae9e..f0dd4cc134 100644 --- a/server/mpm/threaded/threaded.c +++ b/server/mpm/threaded/threaded.c @@ -478,7 +478,6 @@ 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); if (current_conn) { ap_process_connection(current_conn); - ap_lingering_close(current_conn); } } diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 2f25b1ce66..daa9724710 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -901,7 +901,6 @@ static void worker_main(int thread_num) apr_getsocketopt(context->sock, APR_SO_DISCONNECTED, &disconnected); if (!disconnected) { context->accept_socket = INVALID_SOCKET; - ap_lingering_close(c); } } else { diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c index 4e15eaa3e6..0ea7ae6d8f 100644 --- a/server/mpm/worker/worker.c +++ b/server/mpm/worker/worker.c @@ -502,7 +502,6 @@ 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); if (current_conn) { ap_process_connection(current_conn); - ap_lingering_close(current_conn); } }