]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
ctl: link concurrent_ctl_ctx_t to the main socket control thread
authorDavid Vašek <david.vasek@nic.cz>
Fri, 20 Jun 2025 16:11:10 +0000 (18:11 +0200)
committerDavid Vašek <david.vasek@nic.cz>
Tue, 24 Jun 2025 09:09:04 +0000 (11:09 +0200)
src/knot/ctl/threads.c

index c8ed93d3832124c35ef4d2b75498f2ce011372bb..72ee2fc92a4dfe45d310a84fef3612542c86a79e 100644 (file)
@@ -26,6 +26,7 @@ typedef struct {
        pthread_cond_t cond;
        knot_ctl_t *ctl;
        server_t *server;
+       pthread_t socket_thr;
        pthread_t thread;
        int ret;
        unsigned thread_idx;
@@ -33,7 +34,7 @@ typedef struct {
 } concurrent_ctl_ctx_t;
 
 static void ctl_init_ctxs(concurrent_ctl_ctx_t *concurrent_ctxs, size_t n_ctxs,
-                          server_t *server, unsigned thr_idx_from)
+                          server_t *server, unsigned thr_idx_from, pthread_t socket_thr)
 {
        for (size_t i = 0; i < n_ctxs; i++) {
                concurrent_ctl_ctx_t *cctx = &concurrent_ctxs[i];
@@ -41,6 +42,7 @@ static void ctl_init_ctxs(concurrent_ctl_ctx_t *concurrent_ctxs, size_t n_ctxs,
                pthread_mutex_init(&cctx->mutex, NULL);
                pthread_cond_init(&cctx->cond, NULL);
                cctx->server = server;
+               cctx->socket_thr = socket_thr;
                cctx->thread_idx = thr_idx_from + i + 1;
        }
 }
@@ -192,7 +194,7 @@ static int ctl_socket_thr(struct dthread *dt)
        bool thr_exclusive = false, stopped = false;
 
        concurrent_ctl_ctx_t concurrent_ctxs[sock_thr_count];
-       ctl_init_ctxs(concurrent_ctxs, sock_thr_count, ctx->server, thr_idx);
+       ctl_init_ctxs(concurrent_ctxs, sock_thr_count, ctx->server, thr_idx, dt->_thr);
 
        while (dt->unit->threads[0]->state & ThreadActive) {
                if (ctl_cleanup_ctxs(concurrent_ctxs, sock_thr_count) == KNOT_CTL_ESTOP) {