]> 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 19:48:44 +0000 (21:48 +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
(cherry picked from commit 59e1703b50dc4a5c52e3d6ae13bdd873a677b03f)

lib/isc/netmgr/netmgr.c
lib/isc/netmgr/tcp.c
lib/isc/netmgr/tcpdns.c
lib/isc/netmgr/tlsdns.c

index d6188d989972ea8465139b311f37e41b7d0d69bf..256e93967c27fec148b6d8fca3a3cb525281512e 100644 (file)
@@ -1963,6 +1963,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 d52e84c270f107345401eb570543cb8b35e559b8..86c73af57eb4edb68f6038cc1c69277f53b621c9 100644 (file)
@@ -166,7 +166,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);
@@ -220,7 +219,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;
@@ -267,7 +266,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__nm_uverr2result(r);
                                goto error;
                        }
index bafae418b1ab595a8d548a5bca661fbdb889427c..ff9f1380c1c974679cbc9ed3a2474935224c254b 100644 (file)
@@ -136,7 +136,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);
@@ -190,7 +189,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;
@@ -230,7 +229,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__nm_uverr2result(r);
                                goto error;
                        }
index 79b92d5d8366ede0a2d5f5bb4a3630b98c4e765a..aad92bb48767d0f5a33b17a871aac1ea80174fe0 100644 (file)
@@ -174,7 +174,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);
@@ -230,7 +229,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;
@@ -270,7 +269,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__nm_uverr2result(r);
                                goto error;
                        }