2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Refactor the pausing/unpausing and finishing the nm_thread

The isc_nm_pause(), isc_nm_resume() and finishing the nm_thread() from
nm_destroy() has been refactored, so all use the netievents instead of
directly touching the worker structure members.  This allows us to
remove most of the locking as the .paused and .finished members are
always accessed from the matching nm_thread.

When shutting down the nm_thread(), instead of issuing uv_stop(), we
just shutdown the .async handler, so all uv_loop_t events are properly
finished first and uv_run() ends gracefully with no outstanding active
handles in the loop.
This commit is contained in:
Ondřej Surý
2020-09-23 21:49:46 +02:00
parent b8b3ddb02f
commit e5ab137ba3
2 changed files with 142 additions and 132 deletions

View File

@@ -153,6 +153,7 @@ typedef enum isc__netievent_type {
netievent_closecb,
netievent_shutdown,
netievent_stop,
netievent_pause,
netievent_prio = 0xff, /* event type values higher than this
* will be treated as high-priority
@@ -161,6 +162,7 @@ typedef enum isc__netievent_type {
*/
netievent_udplisten,
netievent_tcplisten,
netievent_resume,
} isc__netievent_type;
typedef union {
@@ -297,10 +299,9 @@ struct isc_nm {
isc_mempool_t *evpool;
isc_mutex_t evlock;
atomic_uint_fast32_t workers_running;
atomic_uint_fast32_t workers_paused;
uint_fast32_t workers_running;
uint_fast32_t workers_paused;
atomic_uint_fast32_t maxudp;
atomic_bool paused;
/*
* Active connections are being closed and new connections are