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

Convert sock->active to non-atomic variable, cleanup rchildren

The last atomic_bool variable sock->active was converted to non-atomic
bool by properly handling the listening socket case where we were
checking parent socket instead of children sockets.

This is no longer necessary as we properly set the .active to false on
the children sockets.

Additionally, cleanup the .rchildren - the atomic variable was used for
mutex+condition to block until all children were listening, but that's
now being handled by a barrier.

Finally, just remove dead .self and .active_child_connections members of
the netmgr socket.
This commit is contained in:
Ondřej Surý
2023-03-28 17:03:56 +02:00
parent e1a4572fd6
commit 45365adb32
7 changed files with 54 additions and 109 deletions

View File

@@ -477,6 +477,7 @@ struct isc_nmsocket {
/*% Unlocked, RO */
int magic;
uint32_t tid;
isc_refcount_t references;
isc_nmsocket_type type;
isc__networker_t *worker;
@@ -487,8 +488,6 @@ struct isc_nmsocket {
isc_nmsocket_t *parent;
/*% Listener socket this connection was accepted on */
isc_nmsocket_t *listener;
/*% Self socket */
isc_nmsocket_t *self;
/*% TLS stuff */
struct tlsstream {
@@ -580,19 +579,12 @@ struct isc_nmsocket {
/*% Peer address */
isc_sockaddr_t peer;
/* Atomic */
/*% Number of running (e.g. listening) child sockets */
atomic_uint_fast32_t rchildren;
/*%
* Socket is active if it's listening, working, etc. If it's
* closing, then it doesn't make a sense, for example, to
* push handles or reqs for reuse.
*
* We might be accessing sock->parent->active from a different
* thread, so .active has to be atomic.
*/
atomic_bool active;
bool active;
bool destroying;
bool route_sock;
@@ -611,7 +603,6 @@ struct isc_nmsocket {
bool accepting;
bool reading;
bool timedout;
isc_refcount_t references;
/*%
* Established an outgoing connection, as client not server.
@@ -664,8 +655,6 @@ struct isc_nmsocket {
isc_nm_accept_cb_t accept_cb;
void *accept_cbarg;
atomic_int_fast32_t active_child_connections;
bool barriers_initialised;
bool manual_read_timer;
#if ISC_NETMGR_TRACE
@@ -767,18 +756,6 @@ isc__nmsocket_active(isc_nmsocket_t *sock);
* or, for child sockets, 'sock->parent->active'.
*/
bool
isc__nmsocket_deactivate(isc_nmsocket_t *sock);
/*%<
* @brief Deactivate active socket
*
* Atomically deactive the socket by setting @p sock->active or, for child
* sockets, @p sock->parent->active to @c false
*
* @param[in] sock - valid nmsocket
* @return @c false if the socket was already inactive, @c true otherwise
*/
void
isc__nmsocket_clearcb(isc_nmsocket_t *sock);
/*%<