]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use a constant for timeouts in soft-timeout tests
authorArtem Boldariev <artem@boldariev.com>
Thu, 22 Apr 2021 10:29:34 +0000 (13:29 +0300)
committerEvan Hunt <each@isc.org>
Fri, 23 Apr 2021 17:01:42 +0000 (10:01 -0700)
It makes it easier to change the value should the need arise.

lib/isc/tests/doh_test.c
lib/isc/tests/netmgr_test.c

index ec7c8883c9003b71e5936acfe0eb1c7ceb9ea7ff..71dedbad6af0275699abaddad2f8752cd79028f3 100644 (file)
@@ -77,6 +77,9 @@ static atomic_bool use_TLS = ATOMIC_VAR_INIT(false);
 static isc_tlsctx_t *server_tlsctx = NULL;
 static isc_tlsctx_t *client_tlsctx = NULL;
 
+/* Timeout for soft-timeout tests (0.05 seconds) */
+#define T_SOFT 50
+
 #define NSENDS 100
 #define NWRITES 10
 
@@ -577,7 +580,7 @@ timeout_retry_cb(isc_nmhandle_t *handle, isc_result_t eresult,
        atomic_fetch_add(&ctimeouts, 1);
 
        if (eresult == ISC_R_TIMEDOUT && atomic_load(&ctimeouts) < 5) {
-               isc_nmhandle_settimeout(handle, 50);
+               isc_nmhandle_settimeout(handle, T_SOFT);
                return;
        }
 
@@ -636,12 +639,12 @@ doh_timeout_recovery(void **state) {
         * Shorten all the TCP client timeouts to 0.05 seconds.
         * timeout_retry_cb() will give up after five timeouts.
         */
-       isc_nm_settimeouts(connect_nm, 50, 50, 50, 50);
+       isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT);
        sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url),
                        DOH_PATH);
        isc_nm_httpconnect(connect_nm, NULL, (isc_nmiface_t *)&tcp_listen_addr,
                           req_url, atomic_load(&POST), timeout_request_cb,
-                          NULL, ctx, 50, 0);
+                          NULL, ctx, T_SOFT, 0);
 
        /*
         * Sleep until sends reaches 5.
index f0c27714cd24f16c8207bce14c2af6f247adec64..8f1ae9ece7726acdec9ddaad8ae9d06e284632c6 100644 (file)
@@ -107,6 +107,9 @@ static isc_nm_recv_cb_t connect_readcb = NULL;
 
 #define NSENDS 100
 
+/* Timeout for soft-timeout tests (0.05 seconds) */
+#define T_SOFT 50
+
 /* Timeouts in miliseconds */
 #define T_INIT      120 * 1000
 #define T_IDLE      120 * 1000
@@ -810,7 +813,7 @@ timeout_retry_cb(isc_nmhandle_t *handle, isc_result_t eresult,
        F();
 
        if (eresult == ISC_R_TIMEDOUT && atomic_load(&csends) < 5) {
-               isc_nmhandle_settimeout(handle, 50);
+               isc_nmhandle_settimeout(handle, T_SOFT);
                connect_send(handle);
                return;
        }
@@ -844,7 +847,7 @@ udp_timeout_recovery(void **state __attribute__((unused))) {
        isc_refcount_increment0(&active_cconnects);
        isc_nm_udpconnect(connect_nm, (isc_nmiface_t *)&udp_connect_addr,
                          (isc_nmiface_t *)&udp_listen_addr, connect_connect_cb,
-                         NULL, 50, 0);
+                         NULL, T_SOFT, 0);
 
        WAIT_FOR_EQ(cconnects, 1);
        WAIT_FOR_GE(csends, 1);
@@ -1275,10 +1278,10 @@ stream_timeout_recovery(void **state __attribute__((unused))) {
        /*
         * Shorten all the client timeouts to 0.05 seconds.
         */
-       isc_nm_settimeouts(connect_nm, 50, 50, 50, 50);
+       isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT);
        connect_readcb = timeout_retry_cb;
        isc_refcount_increment0(&active_cconnects);
-       stream_connect(connect_connect_cb, NULL, 50, 0);
+       stream_connect(connect_connect_cb, NULL, T_SOFT, 0);
 
        WAIT_FOR_EQ(cconnects, 1);
        WAIT_FOR_GE(csends, 1);
@@ -1836,11 +1839,11 @@ tcpdns_timeout_recovery(void **state __attribute__((unused))) {
         * timeout_retry_cb() will give up after five timeouts.
         */
        connect_readcb = timeout_retry_cb;
-       isc_nm_settimeouts(connect_nm, 50, 50, 50, 50);
+       isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT);
        isc_refcount_increment0(&active_cconnects);
        isc_nm_tcpdnsconnect(connect_nm, (isc_nmiface_t *)&tcp_connect_addr,
                             (isc_nmiface_t *)&tcp_listen_addr,
-                            connect_connect_cb, NULL, 50, 0);
+                            connect_connect_cb, NULL, T_SOFT, 0);
 
        WAIT_FOR_EQ(cconnects, 1);
        WAIT_FOR_GE(csends, 1);
@@ -2429,11 +2432,11 @@ tlsdns_timeout_recovery(void **state __attribute__((unused))) {
         * timeout_retry_cb() will give up after five timeouts.
         */
        connect_readcb = timeout_retry_cb;
-       isc_nm_settimeouts(connect_nm, 50, 50, 50, 50);
+       isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT);
        isc_refcount_increment0(&active_cconnects);
        isc_nm_tlsdnsconnect(connect_nm, (isc_nmiface_t *)&tcp_connect_addr,
                             (isc_nmiface_t *)&tcp_listen_addr,
-                            connect_connect_cb, NULL, 50, 0,
+                            connect_connect_cb, NULL, T_SOFT, 0,
                             tcp_connect_tlsctx);
 
        WAIT_FOR_EQ(cconnects, 1);