]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1801144, r1801148, r1801456 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 11 Sep 2018 11:54:34 +0000 (11:54 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 11 Sep 2018 11:54:34 +0000 (11:54 +0000)
mpm_winnt: Factor out a helper function to parse the type of an accept
filter and use an appropriate enum for it.

This makes the code in winnt_accept() a bit easier to follow.  As a minor
side effect, it also fixes a small bug where the "unrecognized AcceptFilter
'%s'" log entry would always contain "none" instead of the actually
unrecognized kind of the accept filter.

mpm_winnt: Fix typo in the logged message in winnt_get_connection().

mpm_winnt: Following up on r1801144, use the new accept_filter_e enum
values in a couple of missed places in winnt_accept().

Submitted by: kotkov
Reviewed by: jailletc36, jim (via inspection), wrowe

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1840546 13f79535-47bb-0310-9956-ffa450edef68

STATUS
server/mpm/winnt/child.c

diff --git a/STATUS b/STATUS
index 36ee731505d090601c9ba81e05b9bc3d5d28d6e7..642d5c505599900095b786ca6898336a7b68337a 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -124,20 +124,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) kotkov has made mamy improvements to the mpm_winnt about one year ago.
-     None of them have been merged or proposed for backport yet.
-     Start the merge process with the first easy steps in order to synch
-     2.4.x and trunk and ease other merges
-     - mpm_winnt: Factor out a helper function to parse the type of an accept
-                  filter and use an appropriate enum for it
-     - mpm_winnt: fix typo
-     - mpm_winnt: follow-up to r1801144
-     trunk patch: http://svn.apache.org/r1801144
-                  http://svn.apache.org/r1801148
-                  http://svn.apache.org/r1801456
-     2.4.x patch: svn merge -c 1801144,1801148,1801456 ^/httpd/httpd/trunk . 
-     +1: jailletc36, jim (via inspection), wrowe
-
    *) mod_proxy: fix load order dep between mod_proxy and lbmethod providers
       trunk patch: http://svn.apache.org/r1836381 
                    http://svn.apache.org/r1836382 
index 99e8d3e3436467e77b9061cf8023882971bb4bba..9ddba18f80a4145e676faa5dcfa652ac4008f83d 100644 (file)
@@ -279,6 +279,57 @@ static winnt_conn_ctx_t *mpm_get_completion_context(int *timeout)
     return context;
 }
 
+typedef enum {
+    ACCEPT_FILTER_NONE = 0,
+    ACCEPT_FILTER_CONNECT = 1
+} accept_filter_e;
+
+static const char * accept_filter_to_string(accept_filter_e accf)
+{
+    switch (accf) {
+    case ACCEPT_FILTER_NONE:
+        return "none";
+    case ACCEPT_FILTER_CONNECT:
+        return "connect";
+    default:
+        return "";
+    }
+}
+
+static accept_filter_e get_accept_filter(const char *protocol)
+{
+    core_server_config *core_sconf;
+    const char *name;
+
+    core_sconf = ap_get_core_module_config(ap_server_conf->module_config);
+    name = apr_table_get(core_sconf->accf_map, protocol);
+    if (!name) {
+        ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf,
+                     APLOGNO(02531) "winnt_accept: Listen protocol '%s' has "
+                     "no known accept filter. Using 'none' instead",
+                     protocol);
+        return ACCEPT_FILTER_NONE;
+    }
+    else if (strcmp(name, "data") == 0) {
+        ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
+                     APLOGNO(03458) "winnt_accept: 'data' accept filter is no "
+                     "longer supported. Using 'connect' instead");
+        return ACCEPT_FILTER_CONNECT;
+    }
+    else if (strcmp(name, "connect") == 0) {
+        return ACCEPT_FILTER_CONNECT;
+    }
+    else if (strcmp(name, "none") == 0) {
+        return ACCEPT_FILTER_NONE;
+    }
+    else {
+        ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, APLOGNO(00331)
+                     "winnt_accept: unrecognized AcceptFilter '%s', "
+                     "only 'data', 'connect' or 'none' are valid. "
+                     "Using 'none' instead", name);
+        return ACCEPT_FILTER_NONE;
+    }
+}
 
 /* Windows NT/2000 specific code...
  * Accept processing for on Windows NT uses a producer/consumer queue
@@ -307,10 +358,8 @@ static unsigned int __stdcall winnt_accept(void *lr_)
     LPFN_GETACCEPTEXSOCKADDRS lpfnGetAcceptExSockaddrs = NULL;
     GUID GuidAcceptEx = WSAID_ACCEPTEX;
     GUID GuidGetAcceptExSockaddrs = WSAID_GETACCEPTEXSOCKADDRS;
-    core_server_config *core_sconf;
-    const char *accf_name;
     int rv;
-    int accf;
+    accept_filter_e accf;
     int err_count = 0;
     HANDLE events[3];
 #if APR_HAVE_IPV6
@@ -319,37 +368,6 @@ static unsigned int __stdcall winnt_accept(void *lr_)
 #endif
     u_long zero = 0;
 
-    core_sconf = ap_get_core_module_config(ap_server_conf->module_config);
-    accf_name = apr_table_get(core_sconf->accf_map, lr->protocol);
-
-    if (!accf_name) {
-        accf = 0;
-        accf_name = "none";
-        ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf,
-                     APLOGNO(02531) "winnt_accept: Listen protocol '%s' has "
-                     "no known accept filter. Using 'none' instead",
-                     lr->protocol);
-    }
-    else if (strcmp(accf_name, "data") == 0) {
-        accf = 1;
-        accf_name = "connect";
-        ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
-                     APLOGNO(03458) "winnt_accept: 'data' accept filter is no "
-                     "longer supported. Using 'connect' instead");
-    }
-    else if (strcmp(accf_name, "connect") == 0)
-        accf = 1;
-    else if (strcmp(accf_name, "none") == 0)
-        accf = 0;
-    else {
-        accf = 0;
-        accf_name = "none";
-        ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, APLOGNO(00331)
-                     "winnt_accept: unrecognized AcceptFilter '%s', "
-                     "only 'data', 'connect' or 'none' are valid. "
-                     "Using 'none' instead", accf_name);
-    }
-
     apr_os_sock_get(&nlsd, lr->sd);
 
 #if APR_HAVE_IPV6
@@ -362,7 +380,8 @@ static unsigned int __stdcall winnt_accept(void *lr_)
    }
 #endif
 
-    if (accf > 0) /* 'connect' */
+    accf = get_accept_filter(lr->protocol);
+    if (accf == ACCEPT_FILTER_CONNECT)
     {
         if (WSAIoctl(nlsd, SIO_GET_EXTENSION_FUNCTION_POINTER,
                      &GuidAcceptEx, sizeof GuidAcceptEx, 
@@ -386,7 +405,7 @@ static unsigned int __stdcall winnt_accept(void *lr_)
         events[1] = exit_event;
         events[2] = max_requests_per_child_event;
     }
-    else /* accf == 0, 'none' */
+    else /* accf == ACCEPT_FILTER_NONE */
     {
 reinit: /* target of connect upon too many AcceptEx failures */
 
@@ -410,7 +429,7 @@ reinit: /* target of connect upon too many AcceptEx failures */
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(00334)
                  "Child: Accept thread listening on %pI using AcceptFilter %s",
-                 lr->bind_addr, accf_name);
+                 lr->bind_addr, accept_filter_to_string(accf));
 
     while (!shutdown_in_progress) {
         if (!context) {
@@ -433,7 +452,7 @@ reinit: /* target of connect upon too many AcceptEx failures */
             }
         }
 
-        if (accf > 0) /* 'connect' */
+        if (accf == ACCEPT_FILTER_CONNECT)
         {
             char *buf;
 
@@ -506,7 +525,7 @@ reinit: /* target of connect upon too many AcceptEx failures */
                                      "winnt_mpm: falling back to "
                                      "'AcceptFilter none'.");
                         err_count = 0;
-                        accf = 0;
+                        accf = ACCEPT_FILTER_NONE;
                     }
                     continue;
                 }
@@ -523,7 +542,7 @@ reinit: /* target of connect upon too many AcceptEx failures */
                                      "winnt_mpm: falling back to "
                                      "'AcceptFilter none'.");
                         err_count = 0;
-                        accf = 0;
+                        accf = ACCEPT_FILTER_NONE;
                         goto reinit;
                     }
                     continue;
@@ -582,7 +601,7 @@ reinit: /* target of connect upon too many AcceptEx failures */
                                      &context->sa_server, &context->sa_server_len,
                                      &context->sa_client, &context->sa_client_len);
         }
-        else /* (accf = 0)  e.g. 'none' */
+        else /* accf == ACCEPT_FILTER_NONE */
         {
             /* There is no socket reuse without AcceptEx() */
             if (context->accept_socket != INVALID_SOCKET)
@@ -697,7 +716,7 @@ reinit: /* target of connect upon too many AcceptEx failures */
                                    &context->overlapped);
         context = NULL;
     }
-    if (!accf)
+    if (accf == ACCEPT_FILTER_NONE)
         CloseHandle(events[2]);
 
     if (!shutdown_in_progress) {
@@ -735,7 +754,7 @@ static winnt_conn_ctx_t *winnt_get_connection(winnt_conn_ctx_t *context)
         if (!rc) {
             rc = apr_get_os_error();
             ap_log_error(APLOG_MARK, APLOG_DEBUG, rc, ap_server_conf, APLOGNO(00349)
-                         "Child: GetQueuedComplationStatus returned %d",
+                         "Child: GetQueuedCompletionStatus returned %d",
                          rc);
             continue;
         }