mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
fix nmhandle attach/detach errors in tcpdnsconnect_cb()
we need to attach to the statichandle when connecting TCPDNS sockets, same as with UDP.
This commit is contained in:
@@ -1206,7 +1206,8 @@ isc__nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer,
|
||||
UNLOCK(&sock->lock);
|
||||
|
||||
if (sock->type == isc_nm_tcpsocket ||
|
||||
(sock->type == isc_nm_udpsocket && atomic_load(&sock->client)))
|
||||
(sock->type == isc_nm_udpsocket && atomic_load(&sock->client)) ||
|
||||
(sock->type == isc_nm_tcpdnssocket && atomic_load(&sock->client)))
|
||||
{
|
||||
INSIST(sock->statichandle == NULL);
|
||||
|
||||
|
@@ -736,6 +736,7 @@ tcpdnsconnect_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
||||
void *cbarg = conn->cbarg;
|
||||
size_t extrahandlesize = conn->extrahandlesize;
|
||||
isc_nmsocket_t *dnssock = NULL;
|
||||
isc_nmhandle_t *readhandle = NULL;
|
||||
|
||||
REQUIRE(result != ISC_R_SUCCESS || VALID_NMHANDLE(handle));
|
||||
|
||||
@@ -758,7 +759,13 @@ tcpdnsconnect_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
||||
dnssock->tid = isc_nm_tid();
|
||||
|
||||
atomic_init(&dnssock->client, true);
|
||||
dnssock->statichandle = isc__nmhandle_get(dnssock, NULL, NULL);
|
||||
|
||||
readhandle = isc__nmhandle_get(dnssock, NULL, NULL);
|
||||
|
||||
INSIST(dnssock->statichandle != NULL);
|
||||
INSIST(dnssock->statichandle == readhandle);
|
||||
INSIST(readhandle->sock == dnssock);
|
||||
INSIST(dnssock->recv_cb == NULL);
|
||||
|
||||
uv_timer_init(&dnssock->mgr->workers[isc_nm_tid()].loop,
|
||||
&dnssock->timer);
|
||||
@@ -774,7 +781,11 @@ tcpdnsconnect_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
||||
* packet.
|
||||
*/
|
||||
isc_nm_read(handle, dnslisten_readcb, dnssock);
|
||||
cb(dnssock->statichandle, ISC_R_SUCCESS, cbarg);
|
||||
cb(readhandle, ISC_R_SUCCESS, cbarg);
|
||||
|
||||
/*
|
||||
* The sock is now attached to the handle.
|
||||
*/
|
||||
isc__nmsocket_detach(&dnssock);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user