From: Evan Hunt Date: Thu, 16 Jul 2020 00:57:58 +0000 (-0700) Subject: limit the time we wait for netmgr to be destroyed X-Git-Tag: v9.17.6~64^2~2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=2f2d60a9898faeeb8e9c8d7b80061d7e7845687c;p=thirdparty%2Fbind9.git limit the time we wait for netmgr to be destroyed 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. --- diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 4c6fdde1b24..ea5a54d0cda 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -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. */