From: Bill Stoddard Date: Tue, 20 Nov 2001 19:03:21 +0000 (+0000) Subject: Win32 bug fix: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d35b8d53f02feda157e90af5b5487ba6c6e4458d;p=apache Win32 bug fix: Move call to setsockopt(SO_UPDATE_ACCEPT_CONTEXT) (to cause the accept socket to inherit the listener attributes) to after a connection has been accepted. This piece of code prior to this fix was just wrong; not sure why I never saw warning messages on NT or 2000. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92055 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index fa9c511136..3051d296f4 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -719,7 +719,6 @@ static void winnt_accept(void *listen_socket) continue; } - again: /* Create and initialize the accept socket */ if (pCompContext->accept_socket == INVALID_SOCKET) { @@ -730,15 +729,6 @@ static void winnt_accept(void *listen_socket) "winnt_accept: socket() failed. Process will exit."); // return -1; } - - /* SO_UPDATE_ACCEPT_CONTEXT is required for shutdown() to work */ - if (setsockopt(pCompContext->accept_socket, SOL_SOCKET, - SO_UPDATE_ACCEPT_CONTEXT, (char *)&nlsd, - sizeof(nlsd))) { - ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(), ap_server_conf, - "setsockopt(SO_UPDATE_ACCEPT_CONTEXT) failed."); - /* Not a failure condition. Keep running. */ - } } /* AcceptEx on the completion context. The completion context will be @@ -775,6 +765,16 @@ static void winnt_accept(void *listen_socket) WaitForSingleObject(pCompContext->Overlapped.hEvent, INFINITE); } + /* Inherit the listen socket settings. Required for + * shutdown() to work + */ + if (setsockopt(pCompContext->accept_socket, SOL_SOCKET, + SO_UPDATE_ACCEPT_CONTEXT, (char *)&nlsd, + sizeof(nlsd))) { + ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(), ap_server_conf, + "setsockopt(SO_UPDATE_ACCEPT_CONTEXT) failed."); + /* Not a failure condition. Keep running. */ + } /* When a connection is received, send an io completion notification to * the ThreadDispatchIOCP. This function could be replaced by * mpm_post_completion_context(), but why do an extra function call...