]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mpm_event: don't kill keepalive connections on connections_above_limit().
authorYann Ylavic <ylavic@apache.org>
Tue, 3 Nov 2020 23:58:35 +0000 (23:58 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 3 Nov 2020 23:58:35 +0000 (23:58 +0000)
Before r1819855 (backported to 2.4.30), mpm_event killed keepalive connections
only when workers were exhausted, while this commit set workers_were_busy for
connections_above_limit().

Restore prior to r1819855 behaviour, and since ap_queue_info_num_idlers() is
now part of connections_above_limit(), let's update workers_were_busy there
only when necessary.

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

changes-entries/event_keepalive_above_limit.txt [new file with mode: 0644]
server/mpm/event/event.c

diff --git a/changes-entries/event_keepalive_above_limit.txt b/changes-entries/event_keepalive_above_limit.txt
new file mode 100644 (file)
index 0000000..4360fa4
--- /dev/null
@@ -0,0 +1,4 @@
+  *) mpm_event: kill connections in keepalive state only when there is no more
+     workers available, not when the maximum number of connections is reached,
+     restoring prior to 2.4.30 behaviour.  [Yann Ylavic]
+
index d949a0ad742775d06e254f72de80fa592e6f5cb5..bcd711323cd4fcd2a1a016f07fe67d9431c5271b 100644 (file)
@@ -534,7 +534,7 @@ static APR_INLINE apr_uint32_t listeners_disabled(void)
     return apr_atomic_read32(&listensocks_disabled);
 }
 
-static APR_INLINE int connections_above_limit(void)
+static APR_INLINE int connections_above_limit(int *busy)
 {
     apr_uint32_t i_count = ap_queue_info_num_idlers(worker_queue_info);
     if (i_count > 0) {
@@ -548,6 +548,9 @@ static APR_INLINE int connections_above_limit(void)
             return 0;
         }
     }
+    else if (busy) {
+        *busy = 1;
+    }
     return 1;
 }
 
@@ -809,7 +812,7 @@ static apr_status_t decrement_connection_count(void *cs_)
     is_last_connection = !apr_atomic_dec32(&connection_count);
     if (listener_is_wakeable
             && ((is_last_connection && listener_may_exit)
-                || (listeners_disabled() && !connections_above_limit()))) {
+                || (listeners_disabled() && !connections_above_limit(NULL)))) {
         apr_pollset_wakeup(event_pollset);
     }
     return APR_SUCCESS;
@@ -2066,7 +2069,7 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
                                  "All workers busy, not accepting new conns "
                                  "in this process");
                 }
-                else if (connections_above_limit()) {
+                else if (connections_above_limit(&workers_were_busy)) {
                     disable_listensocks();
                     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
                                  APLOGNO(03269)
@@ -2076,7 +2079,6 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
                     ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf,
                                  "Idle workers: %u",
                                  ap_queue_info_num_idlers(worker_queue_info));
-                    workers_were_busy = 1;
                 }
                 else if (!listener_may_exit) {
                     void *csd = NULL;
@@ -2257,7 +2259,7 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
 
         if (listeners_disabled()
                 && !workers_were_busy
-                && !connections_above_limit()) {
+                && !connections_above_limit(NULL)) {
             enable_listensocks();
         }
     } /* listener main loop */