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

Use barriers for netmgr synchronization

The netmgr listening, stoplistening, pausing and resuming functions
now use barriers for synchronization, which makes the code much simpler.

isc/barrier.h defines isc_barrier macros as a front-end for uv_barrier
on platforms where that works, and pthread_barrier where it doesn't
(including TSAN builds).
This commit is contained in:
Ondřej Surý
2021-05-05 11:51:39 +02:00
committed by Evan Hunt
parent 2eae7813b6
commit 4c8f6ebeb1
14 changed files with 589 additions and 328 deletions

View File

@@ -19,6 +19,7 @@
#include <isc/astack.h>
#include <isc/atomic.h>
#include <isc/barrier.h>
#include <isc/buffer.h>
#include <isc/condition.h>
#include <isc/magic.h>
@@ -174,7 +175,6 @@ typedef struct isc__networker {
uv_async_t async; /* async channel to send
* data to this networker */
isc_mutex_t lock;
isc_condition_t cond;
bool paused;
bool finished;
isc_thread_t thread;
@@ -185,6 +185,8 @@ typedef struct isc__networker {
* used for listening etc.
* can be processed while
* worker is paused */
isc_condition_t cond_prio;
isc_refcount_t references;
atomic_int_fast64_t pktcount;
char *recvbuf;
@@ -671,7 +673,7 @@ struct isc_nm {
isc_mutex_t evlock;
uint_fast32_t workers_running;
uint_fast32_t workers_paused;
atomic_uint_fast32_t workers_paused;
atomic_uint_fast32_t maxudp;
atomic_bool paused;
@@ -702,6 +704,9 @@ struct isc_nm {
atomic_uint_fast32_t keepalive;
atomic_uint_fast32_t advertised;
isc_barrier_t pausing;
isc_barrier_t resuming;
#ifdef NETMGR_TRACE
ISC_LIST(isc_nmsocket_t) active_sockets;
#endif
@@ -836,6 +841,9 @@ struct isc_nmsocket {
/*% Self socket */
isc_nmsocket_t *self;
isc_barrier_t startlistening;
isc_barrier_t stoplistening;
/*% TLS stuff */
struct tls {
isc_tls_t *tls;
@@ -930,7 +938,7 @@ struct isc_nmsocket {
/* Atomic */
/*% Number of running (e.g. listening) child sockets */
uint_fast32_t rchildren;
atomic_uint_fast32_t rchildren;
/*%
* Socket is active if it's listening, working, etc. If it's