From: Artem Boldariev Date: Mon, 26 Apr 2021 19:52:59 +0000 (+0300) Subject: Avoid creating connect netievents during low level failures in HTTP X-Git-Tag: v9.17.13~9^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0d3f503dc93f4c85979b203a07281819b944b700;p=thirdparty%2Fbind9.git Avoid creating connect netievents during low level failures in HTTP This way we create less netievent objects, not bombarding NM with the messages in case of numerous low-level errors (like too many open files) in e.g. unit tests. --- diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index f82a7ae0201..c2e403a5d02 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -1068,19 +1068,28 @@ http_call_connect_cb(isc_nmsocket_t *sock, isc_nm_http_session_t *session, REQUIRE(sock->connect_cb != NULL); - req = isc__nm_uvreq_get(sock->mgr, sock); - req->cb.connect = sock->connect_cb; - req->cbarg = sock->connect_cbarg; - if (session != NULL) { - session->client_httphandle = httphandle; - req->handle = NULL; - isc_nmhandle_attach(httphandle, &req->handle); + if (result == ISC_R_SUCCESS) { + req = isc__nm_uvreq_get(sock->mgr, sock); + req->cb.connect = sock->connect_cb; + req->cbarg = sock->connect_cbarg; + if (session != NULL) { + session->client_httphandle = httphandle; + req->handle = NULL; + isc_nmhandle_attach(httphandle, &req->handle); + } else { + req->handle = httphandle; + } + + isc__nmsocket_clearcb(sock); + isc__nm_connectcb(sock, req, result, true); } else { - req->handle = httphandle; - } + void *cbarg = sock->connect_cbarg; + isc_nm_cb_t connect_cb = sock->connect_cb; - isc__nmsocket_clearcb(sock); - isc__nm_connectcb(sock, req, result, true); + isc__nmsocket_clearcb(sock); + connect_cb(httphandle, result, cbarg); + isc_nmhandle_detach(&httphandle); + } } static void @@ -1168,6 +1177,7 @@ error: isc_mem_free(mctx, http_sock->h2.connect.uri); } + isc__nmsocket_prep_destroy(http_sock); isc__nmsocket_detach(&http_sock); }