]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
mark loop as shuttingdown earlier in shutdown_cb
authorPavel Březina <pbrezina@redhat.com>
Thu, 5 Dec 2024 11:37:37 +0000 (12:37 +0100)
committerOndřej Surý <ondrej@isc.org>
Tue, 10 Dec 2024 19:18:49 +0000 (19:18 +0000)
`shutdown_trigger_close_cb` is not called in the main loop since
queued events in the `loop->async_trigger`, including loop teardown
(shutdown_server) are processed first, before the `uv_close` callback
is executed..

In order to pass the information to the queued events, it is necessary
to set the flag earlier in the process and not wait for the `uv_close`
callback to trigger.

lib/isc/loop.c

index 44a6239de12ed755cb05f6f5b23369fade417c06..d04c4cc4ad3492384397f40f4ed6ed1ca72db52e 100644 (file)
@@ -140,8 +140,6 @@ static void
 shutdown_trigger_close_cb(uv_handle_t *handle) {
        isc_loop_t *loop = uv_handle_get_data(handle);
 
-       loop->shuttingdown = true;
-
        isc_loop_detach(&loop);
 }
 
@@ -167,6 +165,9 @@ shutdown_cb(uv_async_t *handle) {
        /* Make sure, we can't be called again */
        uv_close(&loop->shutdown_trigger, shutdown_trigger_close_cb);
 
+       /* Mark this loop as shutting down */
+       loop->shuttingdown = true;
+
        if (DEFAULT_LOOP(loopmgr) == CURRENT_LOOP(loopmgr)) {
                /* Stop the signal handlers */
                isc_signal_stop(loopmgr->sigterm);