From 383606d5182dc3d12bd2a8eca648b24db40abd8e Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Sat, 10 Nov 2001 21:07:13 +0000 Subject: [PATCH] Fix the Windows MPM. Windows doesn't always use the lingering close function. If it can re-use the socket, we are better off not calling the function. To fix this, we re-expose the lingering_close function, and we allow the MPM to remove the cleanup. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91839 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_connection.h | 16 ++++++++++++++++ server/connection.c | 2 +- server/mpm/winnt/mpm_winnt.c | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/http_connection.h b/include/http_connection.h index 4abad5ce08..ae00cfd7fa 100644 --- a/include/http_connection.h +++ b/include/http_connection.h @@ -88,6 +88,22 @@ 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 + */ +apr_status_t ap_lingering_close(void *dummy); #endif /* Hooks */ diff --git a/server/connection.c b/server/connection.c index eba68b6510..f03917e4e5 100644 --- a/server/connection.c +++ b/server/connection.c @@ -149,7 +149,7 @@ 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 -static apr_status_t ap_lingering_close(void *dummy) +apr_status_t ap_lingering_close(void *dummy) { char dummybuf[512]; apr_size_t nbytes = sizeof(dummybuf); diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index daa9724710..b6b7d7d668 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -902,6 +902,9 @@ static void worker_main(int thread_num) if (!disconnected) { context->accept_socket = INVALID_SOCKET; } + else { + apr_pool_cleanup_kill(context->ptrans, c, ap_lingering_close); + } } else { /* ap_new_connection closes the socket on failure */ -- 2.40.0