]> granicus.if.org Git - apache/commitdiff
Win32 bug fix:
authorBill Stoddard <stoddard@apache.org>
Tue, 20 Nov 2001 19:03:21 +0000 (19:03 +0000)
committerBill Stoddard <stoddard@apache.org>
Tue, 20 Nov 2001 19:03:21 +0000 (19:03 +0000)
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

server/mpm/winnt/mpm_winnt.c

index fa9c511136524edf8c9f84882cb97d6b3b150596..3051d296f470272f2ebbe5b10bc7c48b79363988 100644 (file)
@@ -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...