]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: When process is full, don't destroy clients waiting on master auth
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 26 Mar 2026 10:19:36 +0000 (12:19 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 2 Apr 2026 20:25:49 +0000 (20:25 +0000)
These clients have already successfully authenticated. Killing their client
is only going to cause errors.

src/login-common/client-common.c

index 16a688924705912f897eafab050d2e502dcdf232..66d14fc3ef5775ca31e20feaad88c03b28456eb3 100644 (file)
@@ -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)