From: Aki Tuomi Date: Fri, 30 May 2025 09:07:27 +0000 (+0300) Subject: lib-auth-client: Make auth lookups stop if master service is killed X-Git-Tag: 2.4.2~537 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4543cda87ce7606166c79517de1b1992b3a041fe;p=thirdparty%2Fdovecot%2Fcore.git lib-auth-client: Make auth lookups stop if master service is killed --- diff --git a/src/lib-auth-client/auth-master.c b/src/lib-auth-client/auth-master.c index 79721d44ab..ab9659c560 100644 --- a/src/lib-auth-client/auth-master.c +++ b/src/lib-auth-client/auth-master.c @@ -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); } diff --git a/src/lib-auth-client/test-auth-master.c b/src/lib-auth-client/test-auth-master.c index ae4389c922..2676fa5efc 100644 --- a/src/lib-auth-client/test-auth-master.c +++ b/src/lib-auth-client/test-auth-master.c @@ -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;