]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: Fix calling avail_overflow_callback with service_count=1
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Jan 2020 14:30:34 +0000 (16:30 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 16 Mar 2021 17:00:06 +0000 (17:00 +0000)
This is used by login processes to kill the oldest connection when all of
the clients and processes for the service are taken. This wasn't working
when service_count=1 because the listeners were closed already.

It's not really useful anymore to even do this kind of a listener closing.
It was originally added in 9217d2426b4f8ece47441357f35d8bb34d97c4eb to
prevent restart problems with long-running login processes. However,
nowadays listeners can be closed via SIGQUIT so this isn't necessary.

src/lib-master/master-service.c

index 8e39d2e7fbf6731e1de7286a7cfe3d77e5768aef..aa36b02e58fb81751395e5ed44f9d5a35498dab8 100644 (file)
@@ -970,12 +970,20 @@ void master_service_client_connection_handled(struct master_service *service,
        if (!master_service_want_listener(service)) {
                i_assert(service->listeners != NULL);
                master_service_io_listeners_remove(service);
-               if (service->service_count_left == 1) {
+               if (service->service_count_left == 1 &&
+                  service->avail_overflow_callback == NULL) {
                        /* we're not going to accept any more connections after
                           this. go ahead and close the connection early. don't
                           do this before calling callback, because it may want
                           to access the listen_fd (e.g. to check socket
-                          permissions). */
+                          permissions).
+
+                          Don't do this if overflow callback is set, because
+                          otherwise it's never called with service_count=1.
+                          Actually this isn't important anymore to do with
+                          any service, since nowadays master can request the
+                          listeners to be closed via SIGQUIT. Still, closing
+                          the fd when possible saves a little bit of memory. */
                        master_service_io_listeners_close(service);
                }
        }