Commit 7c3e3429 authored by Ondřej Surý's avatar Ondřej Surý

Use isc_refcount_increment0() where appropriate

parent 9ce3254a
...@@ -91,7 +91,7 @@ dns_lib_init(void) { ...@@ -91,7 +91,7 @@ dns_lib_init(void) {
if (!initialize_done) if (!initialize_done)
return (ISC_R_FAILURE); return (ISC_R_FAILURE);
isc_refcount_increment(&references); isc_refcount_increment0(&references);
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
......
...@@ -1818,7 +1818,7 @@ delete_node(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node) { ...@@ -1818,7 +1818,7 @@ delete_node(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node) {
static inline void static inline void
new_reference(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node) { new_reference(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node) {
INSIST(!ISC_LINK_LINKED(node, deadlink)); INSIST(!ISC_LINK_LINKED(node, deadlink));
if (isc_refcount_increment(&node->references) == 0) { if (isc_refcount_increment0(&node->references) == 0) {
/* this is the first reference to the node */ /* this is the first reference to the node */
isc_refcount_increment0(&rbtdb->node_locks[node->locknum].references); isc_refcount_increment0(&rbtdb->node_locks[node->locknum].references);
} }
......
...@@ -2489,7 +2489,7 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type, ...@@ -2489,7 +2489,7 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type,
abort(); abort();
} }
sock->threadid = gen_threadid(sock); sock->threadid = gen_threadid(sock);
isc_refcount_increment(&sock->references); isc_refcount_increment0(&sock->references);
thread = &manager->threads[sock->threadid]; thread = &manager->threads[sock->threadid];
*socketp = (isc_socket_t *)sock; *socketp = (isc_socket_t *)sock;
...@@ -3149,7 +3149,7 @@ process_fd(isc__socketthread_t *thread, int fd, bool readable, ...@@ -3149,7 +3149,7 @@ process_fd(isc__socketthread_t *thread, int fd, bool readable,
return; return;
} }
if (isc_refcount_increment(&sock->references) == 0) { if (isc_refcount_increment0(&sock->references) == 0) {
/* /*
* Sock is being closed, it will be destroyed, bail. * Sock is being closed, it will be destroyed, bail.
*/ */
...@@ -4678,7 +4678,7 @@ isc_socket_accept(isc_socket_t *sock0, ...@@ -4678,7 +4678,7 @@ isc_socket_accept(isc_socket_t *sock0,
UNLOCK(&sock->lock); UNLOCK(&sock->lock);
return (ISC_R_SHUTTINGDOWN); return (ISC_R_SHUTTINGDOWN);
} }
isc_refcount_increment(&nsock->references); isc_refcount_increment0(&nsock->references);
nsock->statsindex = sock->statsindex; nsock->statsindex = sock->statsindex;
dev->ev_sender = ntask; dev->ev_sender = ntask;
......
...@@ -1736,7 +1736,7 @@ isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp) { ...@@ -1736,7 +1736,7 @@ isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp) {
CONSISTENT(sock); CONSISTENT(sock);
UNLOCK(&sock->lock); UNLOCK(&sock->lock);
isc_refcount_increment(&sock->references); isc_refcount_increment0(&sock->references);
*socketp = sock; *socketp = sock;
} }
...@@ -3114,7 +3114,7 @@ isc_socket_accept(isc_socket_t *sock, ...@@ -3114,7 +3114,7 @@ isc_socket_accept(isc_socket_t *sock,
UNLOCK(&sock->lock); UNLOCK(&sock->lock);
return (ISC_R_SHUTTINGDOWN); return (ISC_R_SHUTTINGDOWN);
} }
isc_refcount_increment(&nsock->references); isc_refcount_increment0(&nsock->references);
adev->ev_sender = ntask; adev->ev_sender = ntask;
adev->newsocket = nsock; adev->newsocket = nsock;
......
...@@ -2347,7 +2347,7 @@ clientmgr_attach(ns_clientmgr_t *source, ns_clientmgr_t **targetp) { ...@@ -2347,7 +2347,7 @@ clientmgr_attach(ns_clientmgr_t *source, ns_clientmgr_t **targetp) {
REQUIRE(VALID_MANAGER(source)); REQUIRE(VALID_MANAGER(source));
REQUIRE(targetp != NULL && *targetp == NULL); REQUIRE(targetp != NULL && *targetp == NULL);
oldrefs = isc_refcount_increment(&source->references); oldrefs = isc_refcount_increment0(&source->references);
isc_log_write(ns_lctx, NS_LOGCATEGORY_CLIENT, isc_log_write(ns_lctx, NS_LOGCATEGORY_CLIENT,
NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3), NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
"clientmgr @%p attach: %d", source, oldrefs + 1); "clientmgr @%p attach: %d", source, oldrefs + 1);
...@@ -2478,7 +2478,6 @@ ns_clientmgr_destroy(ns_clientmgr_t **managerp) { ...@@ -2478,7 +2478,6 @@ ns_clientmgr_destroy(ns_clientmgr_t **managerp) {
isc_result_t result; isc_result_t result;
ns_clientmgr_t *manager; ns_clientmgr_t *manager;
bool unlock = false; bool unlock = false;
int32_t oldrefs;
REQUIRE(managerp != NULL); REQUIRE(managerp != NULL);
manager = *managerp; manager = *managerp;
...@@ -2502,8 +2501,7 @@ ns_clientmgr_destroy(ns_clientmgr_t **managerp) { ...@@ -2502,8 +2501,7 @@ ns_clientmgr_destroy(ns_clientmgr_t **managerp) {
isc_task_endexclusive(manager->excl); isc_task_endexclusive(manager->excl);
} }
oldrefs = isc_refcount_decrement(&manager->references); if (isc_refcount_decrement(&manager->references) == 1) {
if (oldrefs == 1) {
clientmgr_destroy(manager); clientmgr_destroy(manager);
} }
......
...@@ -68,7 +68,7 @@ ns_lib_init(void) { ...@@ -68,7 +68,7 @@ ns_lib_init(void) {
if (!initialize_done) if (!initialize_done)
return (ISC_R_FAILURE); return (ISC_R_FAILURE);
isc_refcount_increment(&references); isc_refcount_increment0(&references);
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment