Description: Add upstream patch to fix active daemon accounting
Author: Ondřej Surý <ondrej@sury.org>
Forwarded: not-needed
Reviewed-By: Yadd <yadd@debian.org>
Last-Update: 2022-03-14

--- a/server/mpm/event/event.c
+++ b/server/mpm/event/event.c
@@ -1864,11 +1864,9 @@
                 else if (connections_above_limit(&workers_were_busy)) {
                     disable_listensocks();
                     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
-                                 "Too many open connections (%u), "
+                                 "Too many open connections (%u, %u idlers), "
                                  "not accepting new conns in this process",
-                                 apr_atomic_read32(&connection_count));
-                    ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, ap_server_conf,
-                                 "Idle workers: %u",
+                                 apr_atomic_read32(&connection_count),
                                  ap_queue_info_num_idlers(worker_queue_info));
                 }
                 else if (!listener_may_exit) {
@@ -2173,6 +2171,12 @@
         }
     }
 
+#if 0
+    if (is_idle) {
+        ap_queue_info_unset_idle(worker_queue_info);
+    }
+#endif
+
     ap_update_child_status_from_indexes(process_slot, thread_slot,
                                         dying ? SERVER_DEAD
                                               : SERVER_GRACEFUL, NULL);
@@ -2817,6 +2821,12 @@
     int i, j;
 
     for (i = 0; i < server_limit; ++i) {
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
+                     "perform_idle_server_maintenance(%i/%i): "
+                     "slot %i/%i, free %i/%i",
+                     child_bucket, num_buckets,
+                     i, retained->max_daemons_limit,
+                     free_length, retained->idle_spawn_rate[child_bucket]);
         if (num_buckets > 1 && (i % num_buckets) != child_bucket) {
             /* We only care about child_bucket in this call */
             continue;
@@ -2832,6 +2842,13 @@
         ps = &ap_scoreboard_image->parent[i];
         if (ps->pid != 0) {
             int child_threads_active = 0;
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
+                         "perform_idle_server_maintenance(%i/%i): "
+                         "slot %i/%i, pid %i, quiescing %i, daemons %i/%i",
+                         child_bucket, num_buckets,
+                         i, retained->max_daemons_limit,
+                         (int)ps->pid, ps->quiescing,
+                         retained->active_daemons, retained->total_daemons);
             if (ps->quiescing == 1) {
                 ps->quiescing = 2;
                 retained->active_daemons--;
@@ -3069,6 +3086,12 @@
 
                 event_note_child_killed(child_slot, 0, 0);
                 ps = &ap_scoreboard_image->parent[child_slot];
+                ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
+                             "server_main_loop(): "
+                             "slot %i/%i, pid %i, quiescing %i, daemons %i/%i",
+                             child_slot, retained->max_daemons_limit,
+                             (int)ps->pid, ps->quiescing,
+                             retained->active_daemons, retained->total_daemons);
                 if (ps->quiescing != 2)
                     retained->active_daemons--;
                 ps->quiescing = 0;
