]> 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)
committerEvan Hunt <each@isc.org>
Fri, 11 Sep 2020 19:17:57 +0000 (12:17 -0700)
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.

lib/isc/netmgr/netmgr.c

index 4c6fdde1b24dd306cb4596d0b1891fed3487022d..ea5a54d0cda476ad13969142486fd704d452046c 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.
         */