From: Bill Stoddard Date: Thu, 11 May 2000 21:17:00 +0000 (+0000) Subject: Create new function, ap_lingering_close(), which will explicitly do a lingering close X-Git-Tag: APACHE_2_0_ALPHA_4~164 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4bd0fe1c282ef667ed22fcd037dabb77c59ffe5f;p=thirdparty%2Fapache%2Fhttpd.git Create new function, ap_lingering_close(), which will explicitly do a lingering close 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 --- diff --git a/server/connection.c b/server/connection.c index 09bdc4861be..1967107c5a9 100644 --- a/server/connection.c +++ b/server/connection.c @@ -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) diff --git a/server/mpm/dexter/dexter.c b/server/mpm/dexter/dexter.c index fa57081da41..ff4387eb2e2 100644 --- a/server/mpm/dexter/dexter.c +++ b/server/mpm/dexter/dexter.c @@ -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 *); diff --git a/server/mpm/mpmt_beos/mpmt_beos.c b/server/mpm/mpmt_beos/mpmt_beos.c index 5556a37fab8..26070299592 100644 --- a/server/mpm/mpmt_beos/mpmt_beos.c +++ b/server/mpm/mpmt_beos/mpmt_beos.c @@ -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) diff --git a/server/mpm/mpmt_pthread/mpmt_pthread.c b/server/mpm/mpmt_pthread/mpmt_pthread.c index e78d354a0bb..9764c2e6576 100644 --- a/server/mpm/mpmt_pthread/mpmt_pthread.c +++ b/server/mpm/mpmt_pthread/mpmt_pthread.c @@ -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) diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index a2b4971862b..237035b659e 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -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); } } diff --git a/server/mpm/spmt_os2/spmt_os2.c b/server/mpm/spmt_os2/spmt_os2.c index bf855051799..2d4218e1209 100644 --- a/server/mpm/spmt_os2/spmt_os2.c +++ b/server/mpm/spmt_os2/spmt_os2.c @@ -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); diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index dfa2d6414bb..f937c85bead 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -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,