From 370757e965b8a63e49fb21e3d1e414c13de36005 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Tue, 3 Nov 2020 23:58:35 +0000 Subject: [PATCH] mpm_event: don't kill keepalive connections on connections_above_limit(). 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 | 4 ++++ server/mpm/event/event.c | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 changes-entries/event_keepalive_above_limit.txt diff --git a/changes-entries/event_keepalive_above_limit.txt b/changes-entries/event_keepalive_above_limit.txt new file mode 100644 index 00000000000..4360fa498f0 --- /dev/null +++ b/changes-entries/event_keepalive_above_limit.txt @@ -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] + diff --git a/server/mpm/event/event.c b/server/mpm/event/event.c index d949a0ad742..bcd711323cd 100644 --- a/server/mpm/event/event.c +++ b/server/mpm/event/event.c @@ -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 */ -- 2.47.3