From 8e27fec274ae9a221eabc02d9bdf80e7e92b51c0 Mon Sep 17 00:00:00 2001 From: Bill Stoddard Date: Fri, 24 May 2002 16:58:23 +0000 Subject: [PATCH] Win32: Shutdown the listeners before telling the accept threads to quit. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95268 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/winnt/mpm_winnt.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 87b125b554..b7f9acd42c 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -1362,21 +1362,25 @@ static void child_main() */ shutdown: - /* Setting is_graceful will cause keep-alive connections to be closed - * rather than block on the next network read. + /* Setting is_graceful will cause threads handling keep-alive connections + * to close the connection after handling the current request. */ is_graceful = 1; - /* Setting shutdown_in_progress prevents new connections from - * being accepted but allows the worker threads to continue - * handling connections that have already been accepted. + /* Close the listening sockets. Note, we must close the listeners + * before closing any accept sockets pending in AcceptEx to prevent + * memory leaks in the kernel. */ - shutdown_in_progress = 1; - - /* Close the listening sockets. */ for (lr = ap_listeners; lr ; lr = lr->next) { apr_socket_close(lr->sd); } + + /* Shutdown listener threads and pending AcceptEx socksts + * but allow the worker threads to continue consuming from + * the queue of accepted connections. + */ + shutdown_in_progress = 1; + Sleep(1000); /* Tell the worker threads to exit */ -- 2.40.0