From: Timo Sirainen Date: Thu, 23 Mar 2023 14:36:10 +0000 (+0200) Subject: master: Add service.process_idling to count number of idling processes X-Git-Tag: 2.3.21~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6cfee1e183f43c9e3efc5e5b2ac90043de9bf65e;p=thirdparty%2Fdovecot%2Fcore.git master: Add service.process_idling to count number of idling processes --- diff --git a/src/master/service-monitor.c b/src/master/service-monitor.c index cb1fdbaf0f..b035d742b6 100644 --- a/src/master/service-monitor.c +++ b/src/master/service-monitor.c @@ -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. */ diff --git a/src/master/service-process.c b/src/master/service-process.c index 929255fb6d..a7935f8138 100644 --- a/src/master/service-process.c +++ b/src/master/service-process.c @@ -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)); diff --git a/src/master/service.h b/src/master/service.h index d422ecbb62..8234d81af4 100644 --- a/src/master/service.h +++ b/src/master/service.h @@ -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 */