mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-04 16:45:24 +00:00
modify reference counting within netmgr
- isc__nmhandle_get() now attaches to the sock in the nmhandle object. the caller is responsible for dereferencing the original socket pointer when necessary. - tcpdns listener sockets attach sock->outer to the outer tcp listener socket. tcpdns connected sockets attach sock->outerhandle to the handle for the tcp connected socket. - only listener sockets need to be attached/detached directly. connected sockets should only be accessed and reference-counted via their associated handles.
This commit is contained in:
committed by
Witold Kręcicki
parent
9e740cad21
commit
5ea26ee1f1
@@ -736,9 +736,15 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree) {
|
||||
isc__nm_decstats(sock->mgr, sock->statsindex[STATID_ACTIVE]);
|
||||
}
|
||||
|
||||
if (sock->tcphandle != NULL) {
|
||||
isc_nmhandle_unref(sock->tcphandle);
|
||||
sock->tcphandle = NULL;
|
||||
sock->tcphandle = NULL;
|
||||
|
||||
if (sock->outerhandle != NULL) {
|
||||
isc_nmhandle_unref(sock->outerhandle);
|
||||
sock->outerhandle = NULL;
|
||||
}
|
||||
|
||||
if (sock->outer != NULL) {
|
||||
isc__nmsocket_detach(&sock->outer);
|
||||
}
|
||||
|
||||
while ((handle = isc_astack_pop(sock->inactivehandles)) != NULL) {
|
||||
@@ -1050,7 +1056,8 @@ isc__nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer,
|
||||
isc_refcount_increment0(&handle->references);
|
||||
}
|
||||
|
||||
handle->sock = sock;
|
||||
isc__nmsocket_attach(sock, &handle->sock);
|
||||
|
||||
if (peer != NULL) {
|
||||
memcpy(&handle->peer, peer, sizeof(isc_sockaddr_t));
|
||||
} else {
|
||||
@@ -1160,7 +1167,7 @@ nmhandle_deactivate(isc_nmsocket_t *sock, isc_nmhandle_t *handle) {
|
||||
|
||||
void
|
||||
isc_nmhandle_unref(isc_nmhandle_t *handle) {
|
||||
isc_nmsocket_t *sock = NULL, *tmp = NULL;
|
||||
isc_nmsocket_t *sock = NULL;
|
||||
|
||||
REQUIRE(VALID_NMHANDLE(handle));
|
||||
|
||||
@@ -1182,7 +1189,6 @@ isc_nmhandle_unref(isc_nmhandle_t *handle) {
|
||||
* be deleted by another thread while we're deactivating the
|
||||
* handle.
|
||||
*/
|
||||
isc__nmsocket_attach(sock, &tmp);
|
||||
nmhandle_deactivate(sock, handle);
|
||||
|
||||
/*
|
||||
@@ -1206,7 +1212,7 @@ isc_nmhandle_unref(isc_nmhandle_t *handle) {
|
||||
}
|
||||
}
|
||||
|
||||
isc__nmsocket_detach(&tmp);
|
||||
isc__nmsocket_detach(&sock);
|
||||
}
|
||||
|
||||
void *
|
||||
|
Reference in New Issue
Block a user