]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
master: Add service.process_idling to count number of idling processes
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 23 Mar 2023 14:36:10 +0000 (16:36 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 11 May 2023 09:12:57 +0000 (12:12 +0300)
src/master/service-monitor.c
src/master/service-process.c
src/master/service.h

index cb1fdbaf0fc8b4b5e0adf732a3b77ee488a4787d..b035d742b6abd2390074425a081dfb1923f8f9e2 100644 (file)
@@ -72,6 +72,9 @@ static void service_status_more(struct service_process *process,
                               &service->idle_processes_tail, process);
                DLLIST_PREPEND(&service->busy_processes, process);
                process->idle_start = 0;
+
+               i_assert(service->process_idling > 0);
+               service->process_idling--;
        }
        process->total_count +=
                process->available_count - status->available_count;
@@ -105,6 +108,7 @@ static void service_check_idle(struct service_process *process)
        if (process->idle_start == 0) {
                /* busy process started idling */
                DLLIST_REMOVE(&service->busy_processes, process);
+               service->process_idling++;
        } else {
                /* Idling process updated its status again to be idling. Maybe
                   it was busy for a little bit? Update its idle_start time. */
index 929255fb6d6eb266f7a31fe0d6f5fa8978155e74..a7935f8138170a74e369c4f42a291ee72d571a72 100644 (file)
@@ -374,6 +374,7 @@ struct service_process *service_process_create(struct service *service)
        service->process_count_total++;
        service->process_count++;
        service->process_avail++;
+       service->process_idling++;
        DLLIST2_APPEND(&service->idle_processes_head,
                       &service->idle_processes_tail, process);
 
@@ -395,6 +396,8 @@ void service_process_destroy(struct service_process *process)
        else {
                DLLIST2_REMOVE(&service->idle_processes_head,
                               &service->idle_processes_tail, process);
+               i_assert(service->process_idling > 0);
+               service->process_idling--;
        }
        hash_table_remove(service_pids, POINTER_CAST(process->pid));
 
index d422ecbb62955f6022afa6ab473fd3403b077d2b..8234d81af447e05d73f55d3012140b916a7e92ba 100644 (file)
@@ -69,6 +69,8 @@ struct service {
        unsigned int process_count;
        /* number of processes currently accepting new clients */
        unsigned int process_avail;
+       /* number of processes currently idling (idle_start != 0) */
+       unsigned int process_idling;
        /* max number of processes allowed */
        unsigned int process_limit;
        /* Total number of processes ever created */