]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Propagate the shutdown event to the recursing ns_client(s)
authorOndřej Surý <ondrej@isc.org>
Thu, 3 Nov 2022 16:42:12 +0000 (17:42 +0100)
committerOndřej Surý <ondrej@isc.org>
Wed, 7 Dec 2022 17:09:40 +0000 (18:09 +0100)
Send the ns_query_cancel() on the recursing clients when we initiate the
named shutdown for faster shutdown.

When we are shutting down the resolver, we cancel all the outstanding
fetches, and the ISC_R_CANCEL events doesn't propagate to the ns_client
callback.

In the future, the better solution how to fix this would be to look at
the shutdown paths and let them all propagate from bottom (loopmgr) to
top (f.e. ns_client).

(cherry picked from commit d861d403bb9a7912e29a06aba6caf6d502839f1b)

lib/ns/client.c
lib/ns/include/ns/client.h
lib/ns/interfacemgr.c
lib/ns/win32/libns.def

index 6bd5ddfdefb9c0d14683078dd23bfe132cda7dab..d4ce000be8744d6c19727bf642b98f3aaa7b8194 100644 (file)
@@ -2518,6 +2518,19 @@ cleanup_reclock:
        return (result);
 }
 
+void
+ns_clientmgr_shutdown(ns_clientmgr_t *manager) {
+       REQUIRE(VALID_MANAGER(manager));
+
+       LOCK(&manager->reclock);
+       for (ns_client_t *client = ISC_LIST_HEAD(manager->recursing);
+            client != NULL; client = ISC_LIST_NEXT(client, rlink))
+       {
+               ns_query_cancel(client);
+       }
+       UNLOCK(&manager->reclock);
+}
+
 void
 ns_clientmgr_destroy(ns_clientmgr_t **managerp) {
        isc_result_t result;
index 9d152c6bbe8ba30f82f66ab42e8eb36441e06a6d..d1e2fde4073027fe4e4c2aed7ce3658b509b8c7a 100644 (file)
@@ -354,12 +354,18 @@ ns_clientmgr_create(isc_mem_t *mctx, ns_server_t *sctx, isc_taskmgr_t *taskmgr,
  */
 
 void
-ns_clientmgr_destroy(ns_clientmgr_t **managerp);
+ns_clientmgr_shutdown(ns_clientmgr_t *manager);
 /*%<
- * Destroy a client manager and all ns_client_t objects
+ * Shutdown a client manager and all ns_client_t objects
  * managed by it.
  */
 
+void
+ns_clientmgr_destroy(ns_clientmgr_t **managerp);
+/*%<
+ * Destroy a client manager.
+ */
+
 isc_sockaddr_t *
 ns_client_getsockaddr(ns_client_t *client);
 /*%<
index 687359058b06b7ee3af74ed78fd987344a3f202c..216e274a54e9de7675773c1df0df3abf6f297f4b 100644 (file)
@@ -574,6 +574,7 @@ ns_interface_shutdown(ns_interface_t *ifp) {
                isc_nmsocket_close(&ifp->tcplistensocket);
        }
        if (ifp->clientmgr != NULL) {
+               ns_clientmgr_shutdown(ifp->clientmgr);
                ns_clientmgr_destroy(&ifp->clientmgr);
        }
 }
index eadd940a9ce1c2a2dad1aaba7dbd0dc7a5a0ab63..50edf86730b065f106ee2a29d34f567291d148dd 100644 (file)
@@ -42,6 +42,7 @@ ns_client_shuttingdown
 ns_client_sourceip
 ns_clientmgr_create
 ns_clientmgr_destroy
+ns_clientmgr_shutdown
 ns_hook_add
 ns_hooktable_create
 ns_hooktable_free