mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
netmgr: actively close all sockets when shutting down server
without this change, named could sometimes lag for a while on shutdown while it waited for open TCP connections to time out.
This commit is contained in:
committed by
Evan Hunt
parent
37354ee225
commit
d6c5052f7e
@@ -309,6 +309,12 @@ isc_nm_destroy(isc_nm_t **mgr0) {
|
||||
mgr = *mgr0;
|
||||
*mgr0 = NULL;
|
||||
|
||||
for (size_t i = 0; i < mgr->nworkers; i++) {
|
||||
isc__netievent_t *event = NULL;
|
||||
event = isc__nm_get_ievent(mgr, netievent_shutdown);
|
||||
isc__nm_enqueue_ievent(&mgr->workers[i], event);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for the manager to be dereferenced elsehwere.
|
||||
*/
|
||||
@@ -512,6 +518,9 @@ async_cb(uv_async_t *handle) {
|
||||
case netievent_closecb:
|
||||
isc__nm_async_closecb(worker, ievent);
|
||||
break;
|
||||
case netievent_shutdown:
|
||||
isc__nm_async_shutdown(worker, ievent);
|
||||
break;
|
||||
default:
|
||||
INSIST(0);
|
||||
ISC_UNREACHABLE();
|
||||
@@ -1174,6 +1183,27 @@ isc__nm_async_closecb(isc__networker_t *worker, isc__netievent_t *ievent0) {
|
||||
isc_nmsocket_detach(&ievent->sock);
|
||||
}
|
||||
|
||||
static void
|
||||
shutdown_walk_cb(uv_handle_t *handle, void *arg) {
|
||||
isc_nmsocket_t *sock = NULL;
|
||||
|
||||
UNUSED(arg);
|
||||
|
||||
switch(handle->type) {
|
||||
case UV_TCP:
|
||||
isc__nm_tcp_shutdown((isc_nmsocket_t *) handle->data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
isc__nm_async_shutdown(isc__networker_t *worker, isc__netievent_t *ievent0) {
|
||||
UNUSED(ievent0);
|
||||
uv_walk(&worker->loop, shutdown_walk_cb, NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
isc__nm_acquire_interlocked(isc_nm_t *mgr) {
|
||||
LOCK(&mgr->lock);
|
||||
|
Reference in New Issue
Block a user