]> 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)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 31 Mar 2023 10:12:57 +0000 (10:12 +0000)
src/master/service-monitor.c
src/master/service-process.c
src/master/service.h

index b0a7a26f3a90e5f0b41ec07bb2eee4af74ad6a67..05abfee89809d868a94a28140f1516ba6318af91 100644 (file)
@@ -73,6 +73,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;
@@ -106,6 +109,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 cf0fd14716ca290acac53c56d0f868e99bf99294..41c60b8e4576e07fbc5aa16eda78a7df1ce8e3ae 100644 (file)
@@ -433,6 +433,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);
 
@@ -467,6 +468,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 87bcf9db3e3bcfb175b7b040fc00a7790fde61a1..2f565a7f444b3e224cbbb584cc3b6dc15339153b 100644 (file)
@@ -72,6 +72,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 */