From: Timo Sirainen Date: Thu, 26 Mar 2026 10:19:36 +0000 (+0200) Subject: login-common: When process is full, don't destroy clients waiting on master auth X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8f5507a2f1fadbb3e29f5f22fec00badf45642a;p=thirdparty%2Fdovecot%2Fcore.git login-common: When process is full, don't destroy clients waiting on master auth These clients have already successfully authenticated. Killing their client is only going to cause errors. --- diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index 16a6889247..66d14fc3ef 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -661,23 +661,25 @@ void client_common_default_free(struct client *client ATTR_UNUSED) bool client_destroy_oldest(bool kill, struct timeval *created_r) { - struct client *client; - - if (last_client == NULL) { - /* we have no clients */ - return FALSE; - } + struct client *client, *last_refcount_non1 = NULL; /* destroy the last client that hasn't successfully authenticated yet. this is usually the last client, but don't kill it if it's just waiting for master to finish its job. Also prefer to kill clients that can immediately be killed (i.e. refcount=1) */ for (client = last_client; client != NULL; client = client->prev) { - if (client->master_tag == 0 && client->refcount == 1) + if (client->master_tag != 0) { + /* never kill clients that are just waiting */ + } else if (client->refcount > 1) + last_refcount_non1 = client; + else break; } - if (client == NULL) - client = last_client; + if (client == NULL) { + client = last_refcount_non1; + if (client == NULL) + return FALSE; + } *created_r = client->created; if (!kill)