]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
ctl: after receiving the 'stop' command, interrupt the socket ctl thread immediately
authorDavid Vašek <david.vasek@nic.cz>
Tue, 27 May 2025 09:13:15 +0000 (11:13 +0200)
committerDavid Vašek <david.vasek@nic.cz>
Tue, 24 Jun 2025 09:09:04 +0000 (11:09 +0200)
This enables quick shutdown without waiting for timeouts in the socket ctl thread.

src/knot/ctl/threads.c

index 72ee2fc92a4dfe45d310a84fef3612542c86a79e..555762028a9650f8e57f1673f6c64916accca7e9 100644 (file)
@@ -111,6 +111,10 @@ static void *ctl_process_thread(void *arg)
 
                pthread_mutex_lock(&ctx->mutex);
                ctx->ret = ret;
+               if (ret == KNOT_CTL_ESTOP) {
+                       // Interrupt main ctl socket thread likely waiting in a syscall.
+                       pthread_kill(ctx->socket_thr, SIGALRM);
+               }
                ctx->exclusive = exclusive;
                if (ctx->state == CONCURRENT_RUNNING) { // not KILLED
                        ctx->state = CONCURRENT_IDLE;