]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Cleanup the STATID_CONNECT and STATID_CONNECTFAIL stat counters
authorOndřej Surý <ondrej@isc.org>
Thu, 14 Jul 2022 11:22:34 +0000 (13:22 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 14 Jul 2022 12:34:53 +0000 (14:34 +0200)
The STATID_CONNECT and STATID_CONNECTFAIL statistics were used
incorrectly. The STATID_CONNECT was incremented twice (once in
the *_connect_direct() and once in the callback) and STATID_CONNECTFAIL
would not be incremented at all if the failure happened in the callback.

Closes: #3452
lib/isc/netmgr/netmgr.c
lib/isc/netmgr/tcp.c
lib/isc/netmgr/tcpdns.c
lib/isc/netmgr/tlsdns.c

index 350117d6f7c5494761c2fa187c29b840078a1d4f..f1a0b94186cf6d81cd4b3e6a10016341e22f54bf 100644 (file)
@@ -1919,6 +1919,8 @@ isc__nm_failed_connect_cb(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
        REQUIRE(sock->tid == isc_nm_tid());
        REQUIRE(req->cb.connect != NULL);
 
+       isc__nm_incstats(sock, STATID_CONNECTFAIL);
+
        isc__nmsocket_timer_stop(sock);
        uv_handle_set_data((uv_handle_t *)&sock->read_timer, sock);
 
index 3d139b0dc19ecfb420a98953942da024bf986f32..6b417963e1e7fcfc22883aa6d7e19d95ba0b27f6 100644 (file)
@@ -165,7 +165,6 @@ tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
                isc__nm_incstats(sock, STATID_CONNECTFAIL);
                goto done;
        }
-       isc__nm_incstats(sock, STATID_CONNECT);
 
        uv_handle_set_data((uv_handle_t *)&sock->read_timer,
                           &req->uv_req.connect);
@@ -219,7 +218,7 @@ isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ev0) {
 
 static void
 tcp_connect_cb(uv_connect_t *uvreq, int status) {
-       isc_result_t result;
+       isc_result_t result = ISC_R_UNSET;
        isc__nm_uvreq_t *req = NULL;
        isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)uvreq->handle);
        struct sockaddr_storage ss;
@@ -266,7 +265,6 @@ tcp_connect_cb(uv_connect_t *uvreq, int status) {
                                           &sock->uv_handle.tcp,
                                           &req->peer.type.sa, tcp_connect_cb);
                        if (r != 0) {
-                               isc__nm_incstats(sock, STATID_CONNECTFAIL);
                                result = isc_uverr2result(r);
                                goto error;
                        }
index 685268eed96a49ead015ba1d214691d4be98f77a..ce281a118f62f95e865410374216414c21c9daae 100644 (file)
@@ -135,7 +135,6 @@ tcpdns_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
                isc__nm_incstats(sock, STATID_CONNECTFAIL);
                goto done;
        }
-       isc__nm_incstats(sock, STATID_CONNECT);
 
        uv_handle_set_data((uv_handle_t *)&sock->read_timer,
                           &req->uv_req.connect);
@@ -189,7 +188,7 @@ isc__nm_async_tcpdnsconnect(isc__networker_t *worker, isc__netievent_t *ev0) {
 
 static void
 tcpdns_connect_cb(uv_connect_t *uvreq, int status) {
-       isc_result_t result;
+       isc_result_t result = ISC_R_UNSET;
        isc__nm_uvreq_t *req = NULL;
        isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)uvreq->handle);
        struct sockaddr_storage ss;
@@ -229,7 +228,6 @@ tcpdns_connect_cb(uv_connect_t *uvreq, int status) {
                                &req->uv_req.connect, &sock->uv_handle.tcp,
                                &req->peer.type.sa, tcpdns_connect_cb);
                        if (r != 0) {
-                               isc__nm_incstats(sock, STATID_CONNECTFAIL);
                                result = isc_uverr2result(r);
                                goto error;
                        }
index 44c546836b503f4173fc57f1c07d5ffa20aab11c..73f153bb9c0abc2d2cf59bf3d1b680fea46bf186 100644 (file)
@@ -173,7 +173,6 @@ tlsdns_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
                isc__nm_incstats(sock, STATID_CONNECTFAIL);
                goto done;
        }
-       isc__nm_incstats(sock, STATID_CONNECT);
 
        uv_handle_set_data((uv_handle_t *)&sock->read_timer,
                           &req->uv_req.connect);
@@ -229,7 +228,7 @@ isc__nm_async_tlsdnsconnect(isc__networker_t *worker, isc__netievent_t *ev0) {
 
 static void
 tlsdns_connect_cb(uv_connect_t *uvreq, int status) {
-       isc_result_t result;
+       isc_result_t result = ISC_R_UNSET;
        isc__nm_uvreq_t *req = NULL;
        isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)uvreq->handle);
        struct sockaddr_storage ss;
@@ -269,7 +268,6 @@ tlsdns_connect_cb(uv_connect_t *uvreq, int status) {
                                &req->uv_req.connect, &sock->uv_handle.tcp,
                                &req->peer.type.sa, tlsdns_connect_cb);
                        if (r != 0) {
-                               isc__nm_incstats(sock, STATID_CONNECTFAIL);
                                result = isc_uverr2result(r);
                                goto error;
                        }