static void
mark_tcp_active(ns_client_t *client, bool active) {
if (active && !client->tcpactive) {
- atomic_fetch_add(&client->interface->ntcpactive, 1);
+ isc_refcount_increment0(&client->interface->ntcpactive);
client->tcpactive = active;
} else if (!active && client->tcpactive) {
uint32_t old =
- atomic_fetch_sub(&client->interface->ntcpactive, 1);
+ isc_refcount_decrement(&client->interface->ntcpactive);
INSIST(old > 0);
client->tcpactive = active;
}
if (client->mortal && TCP_CLIENT(client) &&
client->newstate != NS_CLIENTSTATE_FREED &&
(client->sctx->options & NS_SERVER_CLIENTTEST) == 0 &&
- atomic_load(&client->interface->ntcpaccepting) == 0)
+ isc_refcount_current(&client->interface->ntcpaccepting) == 0)
{
/* Nobody else is accepting */
client->mortal = false;
INSIST(client->naccepts == 1);
client->naccepts--;
- old = atomic_fetch_sub(&client->interface->ntcpaccepting, 1);
+ old = isc_refcount_decrement(&client->interface->ntcpaccepting);
INSIST(old > 0);
/*
* quota is tcp-clients plus the number of listening
* interfaces plus 1.)
*/
- exit = (atomic_load(&client->interface->ntcpactive) >
+ exit = (isc_refcount_current(&client->interface->ntcpactive) >
(client->tcpactive ? 1U : 0U));
if (exit) {
client->newstate = NS_CLIENTSTATE_INACTIVE;
* listening for connections itself to prevent the interface
* going dead.
*/
- atomic_fetch_add(&client->interface->ntcpaccepting, 1);
+ isc_refcount_increment0(&client->interface->ntcpaccepting);
}
static void
#include <isc/magic.h>
#include <isc/mem.h>
#include <isc/socket.h>
+#include <isc/refcount.h>
#include <dns/geoip.h>
#include <dns/result.h>
/*%< UDP dispatchers. */
isc_socket_t * tcpsocket; /*%< TCP socket. */
isc_dscp_t dscp; /*%< "listen-on" DSCP value */
- atomic_uint_fast32_t ntcpaccepting; /*%< Number of clients
+ isc_refcount_t ntcpaccepting; /*%< Number of clients
ready to accept new
TCP connections on this
interface */
- atomic_uint_fast32_t ntcpactive; /*%< Number of clients
+ isc_refcount_t ntcpactive; /*%< Number of clients
servicing TCP queries
(whether accepting or
connected) */
* connections will be handled in parallel even though there is
* only one client initially.
*/
- atomic_init(&ifp->ntcpaccepting, 0);
- atomic_init(&ifp->ntcpactive, 0);
+ isc_refcount_init(&ifp->ntcpaccepting, 0);
+ isc_refcount_init(&ifp->ntcpactive, 0);
ifp->nudpdispatch = 0;
ns_interfacemgr_detach(&ifp->mgr);
+ isc_refcount_destroy(&ifp->ntcpactive);
+ isc_refcount_destroy(&ifp->ntcpaccepting);
+
ifp->magic = 0;
isc_mem_put(mctx, ifp, sizeof(*ifp));
}