From: Ondřej Surý Date: Tue, 9 May 2023 08:24:37 +0000 (+0200) Subject: Adjust the udp_shutdown_connect to delay the check X-Git-Tag: v9.19.14~55^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0759612418282dcb1165342556f0d6d7e45addb1;p=thirdparty%2Fbind9.git Adjust the udp_shutdown_connect to delay the check The teardown jobs are not executed immediately, so we need to delay the check for ISC_R_SHUTTINGDOWN even more (as the UDP connect is synchronous, it makes it harder to test it). --- diff --git a/tests/isc/udp_test.c b/tests/isc/udp_test.c index c8482e2d1be..5b8a0ba5276 100644 --- a/tests/isc/udp_test.c +++ b/tests/isc/udp_test.c @@ -515,6 +515,9 @@ ISC_LOOP_TEST_IMPL(udp_timeout_recovery) { udp_timeout_recovery_connect_cb, listen_sock, T_SOFT); } +static void +udp_connect_udpconnect(void *arg ISC_ATTR_UNUSED); + static void udp_shutdown_connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) { @@ -523,20 +526,29 @@ udp_shutdown_connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_refcount_decrement(&active_cconnects); - assert_int_equal(eresult, ISC_R_SHUTTINGDOWN); - - atomic_fetch_add(&cconnects, 1); + /* + * The first UDP connect is faster than asynchronous shutdown procedure, + * restart the UDP connect again and expect the failure only in the + * second loop. + */ + if (atomic_fetch_add(&cconnects, 1) == 0) { + assert_int_equal(eresult, ISC_R_SUCCESS); + isc_async_current(loopmgr, udp_connect_udpconnect, netmgr); + } else { + assert_int_equal(eresult, ISC_R_SHUTTINGDOWN); + } } static void udp_connect_udpconnect(void *arg ISC_ATTR_UNUSED) { + isc_refcount_increment0(&active_cconnects); isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr, udp_shutdown_connect_connect_cb, NULL, T_SOFT); } ISC_SETUP_TEST_IMPL(udp_shutdown_connect) { setup_test(state); - expected_cconnects = 1; + expected_cconnects = 2; return (0); } @@ -548,7 +560,10 @@ ISC_TEARDOWN_TEST_IMPL(udp_shutdown_connect) { ISC_LOOP_TEST_IMPL(udp_shutdown_connect) { isc_loopmgr_shutdown(loopmgr); - isc_refcount_increment0(&active_cconnects); + /* + * isc_nm_udpconnect() is synchronous, so we need to launch this on the + * async loop. + */ isc_async_current(loopmgr, udp_connect_udpconnect, netmgr); }