From: Witold Kręcicki Date: Fri, 15 Nov 2019 11:15:03 +0000 (+0100) Subject: netmgr: close uv_loop properly X-Git-Tag: v9.15.6~1^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62a8405fa26d2abb04b906e0bb568ae553f67ce1;p=thirdparty%2Fbind9.git netmgr: close uv_loop properly close the uv_handle for the worker async channel, and call uv_loop_close() on shutdown to ensure that the event loop's internal resources are properly freed. --- diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index da8e73d81e4..3d65bca4572 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -174,6 +174,8 @@ nm_destroy(isc_nm_t **mgr0) { isc_mem_put(mgr->mctx, ievent, sizeof(isc__netievent_storage_t)); } + int r = uv_loop_close(&mgr->workers[i].loop); + INSIST(r == 0); isc_queue_destroy(mgr->workers[i].ievents); isc_mempool_destroy(&mgr->workers[i].mpool_bufs); } @@ -350,6 +352,16 @@ nm_thread(void *worker0) { if (worker->finished) { /* TODO walk the handles and free them! */ + /* + * We need to launch the loop one more time + * to make sure that worker->async is closed, + * so that we can close the loop cleanly. + * We don't care about the callback as in this + * case we can be certain that uv_run will + * eat this event. + */ + uv_close((uv_handle_t *)&worker->async, NULL); + uv_run(&worker->loop, UV_RUN_NOWAIT); break; }