]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
limit the time we wait for netmgr to be destroyed
authorEvan Hunt <each@isc.org>
Thu, 16 Jul 2020 00:57:58 +0000 (17:57 -0700)
committerOndřej Surý <ondrej@sury.org>
Thu, 1 Oct 2020 16:09:35 +0000 (18:09 +0200)
if more than 10 seconds pass while we wait for netmgr events to
finish running on shutdown, something is almost certainly wrong
and we should assert and crash.

(cherry picked from commit 2f2d60a9898faeeb8e9c8d7b80061d7e7845687c)

lib/isc/netmgr/netmgr.c

index f776ce3127407096e5eedfe6026084d34725b145..ac7f72db1fdcb3a3518ea50a3707396e48cb7c64 100644 (file)
@@ -393,6 +393,7 @@ isc_nm_closedown(isc_nm_t *mgr) {
 void
 isc_nm_destroy(isc_nm_t **mgr0) {
        isc_nm_t *mgr = NULL;
+       int counter = 0;
 
        REQUIRE(mgr0 != NULL);
        REQUIRE(VALID_NM(*mgr0));
@@ -407,7 +408,7 @@ isc_nm_destroy(isc_nm_t **mgr0) {
        /*
         * Wait for the manager to be dereferenced elsewhere.
         */
-       while (isc_refcount_current(&mgr->references) > 1) {
+       while (isc_refcount_current(&mgr->references) > 1 && counter++ < 1000) {
                /*
                 * Sometimes libuv gets stuck, pausing and unpausing
                 * netmgr goes over all events in async queue for all
@@ -423,6 +424,8 @@ isc_nm_destroy(isc_nm_t **mgr0) {
 #endif /* ifdef WIN32 */
        }
 
+       INSIST(counter <= 1000);
+
        /*
         * Detach final reference.
         */