]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make dns_xfrin_shutdown() safe to run from a different loop
authorAram Sargsyan <aram@isc.org>
Tue, 11 Jun 2024 10:57:15 +0000 (10:57 +0000)
committerAram Sargsyan <aram@isc.org>
Thu, 1 Aug 2024 10:43:47 +0000 (10:43 +0000)
If the current loop is different than the zone transfer's loop then
run the shutdown operation asynchronously.

lib/dns/xfrin.c

index 745c7f58a7c210eb8a9c963fc8ebcb3baba7bc90..523b59a5a656a7a890146212a0d79737d6c87205 100644 (file)
@@ -16,6 +16,7 @@
 #include <inttypes.h>
 #include <stdbool.h>
 
+#include <isc/async.h>
 #include <isc/atomic.h>
 #include <isc/mem.h>
 #include <isc/random.h>
@@ -1048,11 +1049,26 @@ dns_xfrin_gettsigkeyname(const dns_xfrin_t *xfr) {
        return (dst_key_name(xfr->tsigkey->key));
 }
 
+static void
+xfrin_shutdown(void *arg) {
+       dns_xfrin_t *xfr = arg;
+
+       REQUIRE(VALID_XFRIN(xfr));
+
+       xfrin_fail(xfr, ISC_R_CANCELED, "shut down");
+       dns_xfrin_detach(&xfr);
+}
+
 void
 dns_xfrin_shutdown(dns_xfrin_t *xfr) {
        REQUIRE(VALID_XFRIN(xfr));
 
-       xfrin_fail(xfr, ISC_R_CANCELED, "shut down");
+       if (xfr->loop != isc_loop()) {
+               dns_xfrin_ref(xfr);
+               isc_async_run(xfr->loop, xfrin_shutdown, xfr);
+       } else {
+               xfrin_fail(xfr, ISC_R_CANCELED, "shut down");
+       }
 }
 
 #if DNS_XFRIN_TRACE