*/
struct dispportentry {
in_port_t port;
- unsigned int refs;
+ isc_refcount_t refs;
ISC_LINK(struct dispportentry) link;
};
return (portentry);
portentry->port = port;
- portentry->refs = 1;
+ isc_refcount_init(&portentry->refs, 1);
ISC_LINK_INIT(portentry, link);
qid = DNS_QID(disp);
LOCK(&qid->lock);
dns_qid_t *qid;
REQUIRE(disp->port_table != NULL);
- REQUIRE(portentry != NULL && portentry->refs > 0);
+ REQUIRE(portentry != NULL && isc_refcount_current(&portentry->refs) > 0);
- qid = DNS_QID(disp);
- LOCK(&qid->lock);
- portentry->refs--;
-
- if (portentry->refs == 0) {
+ if (isc_refcount_decrement(&portentry->refs) == 1) {
+ qid = DNS_QID(disp);
+ LOCK(&qid->lock);
ISC_LIST_UNLINK(disp->port_table[portentry->port %
DNS_DISPATCH_PORTTABLESIZE],
portentry, link);
isc_mempool_put(disp->portpool, portentry);
+ UNLOCK(&qid->lock);
}
/*
+ * XXXWPK TODO: is it really necessary?
* Set '*portentryp' to NULL inside the lock so that
* dispsock->portentry does not change in socket_search.
*/
*portentryp = NULL;
- UNLOCK(&qid->lock);
}
/*%
break;
}
} else {
- LOCK(&qid->lock);
- portentry->refs++;
- UNLOCK(&qid->lock);
+ isc_refcount_increment(&portentry->refs);
}
break;
} else if (result == ISC_R_NOPERM) {