]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-auth-client: Make auth lookups stop if master service is killed
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 30 May 2025 09:07:27 +0000 (12:07 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 26 Aug 2025 10:57:52 +0000 (10:57 +0000)
src/lib-auth-client/auth-master.c
src/lib-auth-client/test-auth-master.c

index 79721d44abff1a83162e3c60af44df44339325f4..ab9659c560adb9483125e2bf996b9e38061322d4 100644 (file)
@@ -13,6 +13,7 @@
 #include "connection.h"
 #include "auth-client-interface.h"
 #include "master-interface.h"
+#include "master-service.h"
 #include "auth-client-private.h"
 #include "auth-master.h"
 
@@ -507,12 +508,23 @@ static int auth_master_run_cmd_post(struct auth_master_connection *conn)
        return 0;
 }
 
+static void auth_master_stop(struct auth_master_connection *conn)
+{
+       if (master_service_is_killed(master_service)) {
+               auth_request_lookup_abort(conn);
+               io_loop_stop(conn->ioloop);
+       }
+}
+
 static int auth_master_run_cmd(struct auth_master_connection *conn,
                               const char *cmd)
 {
        if (auth_master_run_cmd_pre(conn, cmd) < 0)
                return -1;
+       /* add stop handler */
+       struct timeout *to = timeout_add_short(100, auth_master_stop, conn);
        io_loop_run(conn->ioloop);
+       timeout_remove(&to);
        return auth_master_run_cmd_post(conn);
 }
 
index ae4389c9226d7221289c71993b234f4ca8e39611..2676fa5efce2a504133d0624a70e58ed49f3e1e6 100644 (file)
@@ -14,6 +14,7 @@
 #include "write-full.h"
 #include "connection.h"
 #include "master-interface.h"
+#include "master-service.h"
 #include "test-common.h"
 #include "test-subprocess.h"
 
@@ -24,6 +25,8 @@
 #define TEST_SOCKET "./auth-master-test"
 #define SERVER_KILL_TIMEOUT_SECS    20
 
+struct master_service *master_service = NULL;
+
 static void main_deinit(void);
 
 /*
@@ -1412,6 +1415,11 @@ static void main_deinit(void)
        /* nothing yet; also called from sub-processes */
 }
 
+bool master_service_is_killed(struct master_service *service ATTR_UNUSED)
+{
+       return FALSE;
+}
+
 int main(int argc, char *argv[])
 {
        int c;