From: Timo Sirainen Date: Thu, 5 Aug 2021 14:53:58 +0000 (+0300) Subject: master: Avoid high CPU usage when process_min_avail reaches process_limit X-Git-Tag: 2.3.17~245 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0610336a86a24b6034d94c0d26d0e31425f7d1cb;p=thirdparty%2Fdovecot%2Fcore.git master: Avoid high CPU usage when process_min_avail reaches process_limit process_min_avail handling always created a 0ms timeout to try to create the missing processes. This timeout was supposed to stop when it couldn't launch all the wanted processes, but the check wasn't done right. This ended up causing the timeout to be called rapidly over and over again. --- diff --git a/src/master/service-monitor.c b/src/master/service-monitor.c index a0921fa9f9..3e838c9b81 100644 --- a/src/master/service-monitor.c +++ b/src/master/service-monitor.c @@ -351,7 +351,7 @@ service_monitor_start_count(struct service *service, unsigned int limit) /* we created some processes, they'll do the listening now */ service_monitor_listen_stop(service); } - return i == count; + return i >= limit; } static void service_monitor_prefork_timeout(struct service *service) @@ -365,8 +365,12 @@ static void service_monitor_prefork_timeout(struct service *service) } if (service->process_avail < service->set->process_min_avail) { if (service_monitor_start_count(service, SERVICE_PREFORK_MAX_AT_ONCE) && - service->process_avail < service->set->process_min_avail) + service->process_avail < service->set->process_min_avail) { + /* All SERVICE_PREFORK_MAX_AT_ONCE were created, but + it still wasn't enough. Launch more in the next + timeout. */ return; + } } timeout_remove(&service->to_prefork); }