]> granicus.if.org Git - apache/commitdiff
PR#37680: fix socket block/nonblock on restart/graceful
authorNick Kew <niq@apache.org>
Sat, 16 Dec 2006 21:41:38 +0000 (21:41 +0000)
committerNick Kew <niq@apache.org>
Sat, 16 Dec 2006 21:41:38 +0000 (21:41 +0000)
Patch submitted by Darius Davis (darius-abz free-range.com.au)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@487901 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/listen.c

diff --git a/CHANGES b/CHANGES
index d777b8675a82d9783a01c0adb56b0a3828068ec6..1426d8b251fdcaef840909e0ec3c33297f40efdc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) core: Fix NONBLOCK status of listening sockets on restart/graceful
+     [Darius Davis <darius-abz free-range.com.au>]
+
   *) mod_proxy_http: Handle request bodies larger than 2 GB by converting
      the Content-Length header of the request correctly. PR 40883.
      [Ruediger Pluem, toadie <toadie643 gmail.com>]
index ddf874039872451b4f95e816eed9837ea166b6e8..f679f058200f133f5032902fa54232d274f830fa 100644 (file)
@@ -361,6 +361,9 @@ static int open_listeners(apr_pool_t *pool)
     int num_open;
     const char *userdata_key = "ap_open_listeners";
     void *data;
+#if AP_NONBLOCK_WHEN_MULTI_LISTEN
+    int use_nonblock;
+#endif
 
     /* Don't allocate a default listener.  If we need to listen to a
      * port, then the user needs to have a Listen directive in their
@@ -476,16 +479,15 @@ static int open_listeners(apr_pool_t *pool)
      * is already forgotten about by the time we call accept, we won't
      * be hung until another connection arrives on that port
      */
-    if (ap_listeners && ap_listeners->next) {
-        for (lr = ap_listeners; lr; lr = lr->next) {
-            apr_status_t status;
-
-            status = apr_socket_opt_set(lr->sd, APR_SO_NONBLOCK, 1);
-            if (status != APR_SUCCESS) {
-                ap_log_perror(APLOG_MARK, APLOG_STARTUP|APLOG_ERR, status, pool,
-                              "unable to make listening socket non-blocking");
-                return -1;
-            }
+    use_nonblock = (ap_listeners && ap_listeners->next);
+    for (lr = ap_listeners; lr; lr = lr->next) {
+        apr_status_t status;
+
+        status = apr_socket_opt_set(lr->sd, APR_SO_NONBLOCK, use_nonblock);
+        if (status != APR_SUCCESS) {
+            ap_log_perror(APLOG_MARK, APLOG_STARTUP|APLOG_ERR, status, pool,
+                          "unable to control socket non-blocking status");
+            return -1;
         }
     }
 #endif /* AP_NONBLOCK_WHEN_MULTI_LISTEN */