httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1762742 - /httpd/httpd/trunk/server/mpm/event/event.c
Date Thu, 29 Sep 2016 08:15:34 GMT
Author: ylavic
Date: Thu Sep 29 08:15:33 2016
New Revision: 1762742

URL: http://svn.apache.org/viewvc?rev=1762742&view=rev
Log:
event: follow up to r1762718.
We still need to kill kept-alive connections in normal/expiry processing if
the workers are busy or dying.


Modified:
    httpd/httpd/trunk/server/mpm/event/event.c

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1762742&r1=1762741&r2=1762742&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Thu Sep 29 08:15:33 2016
@@ -1796,6 +1796,23 @@ static void process_timeout_queue(struct
     apr_thread_mutex_lock(timeout_mutex);
 }
 
+static void process_keepalive_queue(apr_time_t timeout_time)
+{
+    apr_uint32_t total = apr_atomic_read32(keepalive_q->total);
+    if (total) {
+        /* If all workers are busy, we kill older keep-alive connections so
+         * that they may connect to another process.
+         */
+        if (!timeout_time) {
+            ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf,
+                         "All workers are busy or dying, will close "
+                         "%d keep-alive connections", (int)total);
+        }
+        process_timeout_queue(keepalive_q, timeout_time,
+                              start_lingering_close_nonblocking);
+    }
+}
+
 static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
 {
     apr_status_t rc;
@@ -1834,7 +1851,6 @@ static void * APR_THREAD_FUNC listener_t
         apr_interval_time_t timeout_interval;
         apr_time_t now, timeout_time;
         int workers_were_busy = 0;
-        int keepalives;
 
         if (listener_may_exit) {
             close_listeners(process_slot, &closed);
@@ -2185,8 +2201,12 @@ static void * APR_THREAD_FUNC listener_t
             queues_next_expiry = 0;
 
             /* Step 1: keepalive timeouts */
-            process_timeout_queue(keepalive_q, timeout_time,
-                                  start_lingering_close_nonblocking);
+            if (workers_were_busy || dying) {
+                process_keepalive_queue(0); /* kill'em all \m/ */
+            }
+            else {
+                process_keepalive_queue(timeout_time);
+            }
             /* Step 2: write completion timeouts */
             process_timeout_queue(write_completion_q, timeout_time,
                                   start_lingering_close_nonblocking);
@@ -2205,20 +2225,11 @@ static void * APR_THREAD_FUNC listener_t
             ps->suspended = apr_atomic_read32(&suspended_count);
             ps->lingering_close = apr_atomic_read32(&lingering_count);
         }
-        else if ((workers_were_busy || dying)
-                 && (keepalives = apr_atomic_read32(keepalive_q->total))) {
-            /* If all workers are busy, we kill older keep-alive connections so
-             * that they may connect to another process.
-             */
-            ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf,
-                         "All workers are %s, will close %d keep-alive "
-                         "connections", dying ? "dying" : "busy",
-                         keepalives);
+        else if (workers_were_busy || dying) {
             apr_thread_mutex_lock(timeout_mutex);
-            process_timeout_queue(keepalive_q, 0,
-                                  start_lingering_close_nonblocking);
+            process_keepalive_queue(0); /* kill'em all \m/ */
             apr_thread_mutex_unlock(timeout_mutex);
-            ps->keep_alive = apr_atomic_read32(keepalive_q->total);
+            ps->keep_alive = 0;
         }
 
         if (listeners_disabled && !workers_were_busy



Mime
View raw message