From: Witold Kręcicki Date: Tue, 20 Oct 2020 14:06:54 +0000 (+0200) Subject: Proper handling of socket references in case of TCP conn failure. X-Git-Tag: v9.17.7~46^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff0a336d524c249bf144b121b53d1a3fa66a626d;p=thirdparty%2Fbind9.git Proper handling of socket references in case of TCP conn failure. --- diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 7aef6850584..6c9bcb47d17 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -135,12 +135,15 @@ isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ev0) { if (r != 0) { /* We need to issue callbacks ourselves */ tcp_connect_cb(&req->uv_req.connect, r); - goto done; + LOCK(&sock->lock); + SIGNAL(&sock->cond); + UNLOCK(&sock->lock); + isc__nmsocket_detach(&sock); + return; } atomic_store(&sock->connected, true); -done: LOCK(&sock->lock); SIGNAL(&sock->cond); UNLOCK(&sock->lock); @@ -161,6 +164,7 @@ tcp_connect_cb(uv_connect_t *uvreq, int status) { if (status != 0) { req->cb.connect(NULL, isc__nm_uverr2result(status), req->cbarg); isc__nm_uvreq_put(&req, sock); + isc__nmsocket_detach(&sock); return; } @@ -243,7 +247,6 @@ isc_nm_tcpconnect(isc_nm_t *mgr, isc_nmiface_t *local, isc_nmiface_t *peer, if (nsock->result != ISC_R_SUCCESS) { result = nsock->result; - isc__nmsocket_detach(&nsock); } isc__nmsocket_detach(&tmp);