From: Artem Boldariev Date: Fri, 30 Apr 2021 12:55:21 +0000 (+0300) Subject: TLS: cancel reading on the underlying TCP socket after (see below) X-Git-Tag: v9.17.13~9^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22376fc69a3d2b0a475b53a612c8cca754e60390;p=thirdparty%2Fbind9.git TLS: cancel reading on the underlying TCP socket after (see below) ... the last handle has been detached after calling write callback. That makes it possible to detach from the underlying socket and not to keep the socket object alive for too long. This issue was causing TLS tests with quota to fail because quota might not have been detached on time (because it was still referenced by the underlying TCP socket). One could say that this commit is an ideological continuation of: 513cdb52ecd4e63566672217f7390574f68c4d2d. --- diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index e738d555fbd..264ffcde41e 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -113,8 +113,14 @@ tls_senddone(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) { send_req->tlssock = NULL; if (send_req->cb != NULL) { + INSIST(VALID_NMHANDLE(tlssock->statichandle)); send_req->cb(send_req->handle, eresult, send_req->cbarg); isc_nmhandle_detach(&send_req->handle); + /* The last handle has been just detached: close the underlying + * socket. */ + if (tlssock->statichandle == NULL) { + finish = true; + } } isc_mem_put(handle->sock->mgr->mctx, send_req->data.base,