From 53e835130e5bf3bf55a0d8d2788b4145d2e193a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 12 Jan 2023 21:44:31 +0100 Subject: [PATCH] Allow interrupting dnssec-signzone during signing The signal handler in the isc_loop would wait for all the work to finish before interrupting the signing. Add teardown handlers via isc_loopmgr_teardown() to signal the assignwork() it should stop signing and bail-out early. NOTE: The dnssec-signzone binary still can't be interrupted during zone loading, zone cleaning, nsec(3) chain generation or zone writing. This might get addressed in the future if it becomes a problem. --- bin/dnssec/dnssec-signzone.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 3f8367c477..835dc2737a 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -1544,6 +1544,13 @@ signapex(void) { } } +static void +abortwork(void *arg) { + UNUSED(arg); + + atomic_store(&shuttingdown, true); +} + /*% * Assigns a node to a worker thread. This is protected by the main task's * lock. @@ -3937,13 +3944,13 @@ main(int argc, char *argv[]) { * processors if possible. */ isc_loopmgr_setup(loopmgr, assignwork, NULL); + isc_loopmgr_teardown(loopmgr, abortwork, NULL); isc_loopmgr_run(loopmgr); if (!atomic_load(&finished)) { fatal("process aborted by user"); } } - atomic_store(&shuttingdown, true); postsign(); TIME_NOW(&sign_finish);