From: Ondřej Surý Date: Tue, 11 Oct 2022 07:06:37 +0000 (+0200) Subject: Handle double timeout in udp_cancel_read test X-Git-Tag: v9.19.7~73^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02c42a20b7cabcdd44ee8afdda888a521444258e;p=thirdparty%2Fbind9.git Handle double timeout in udp_cancel_read test If sending took too long the isc_nm_read() could timeout twice, leading to extra 'cread' counter in the udp_cancel_read test. Increase the cread counter only on ISC_R_EOF (canceled read) and deal with the multiple ISC_R_TIMEOUTS gracefully. --- diff --git a/tests/isc/udp_test.c b/tests/isc/udp_test.c index 9644f7c0fa4..c36074e3041 100644 --- a/tests/isc/udp_test.c +++ b/tests/isc/udp_test.c @@ -702,15 +702,17 @@ udp_cancel_read_read_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_nmhandle_attach(handle, &readhandle); isc_nm_read(handle, udp_cancel_read_read_cb, cbarg); - /* Send */ - isc_refcount_increment0(&active_csends); - isc_nmhandle_attach(handle, &sendhandle); - isc_nmhandle_setwritetimeout(handle, T_IDLE); - isc_nm_send(sendhandle, (isc_region_t *)&send_msg, - udp_cancel_read_send_cb, cbarg); + /* Send only once */ + if (isc_refcount_increment0(&active_csends) == 0) { + isc_nmhandle_attach(handle, &sendhandle); + isc_nmhandle_setwritetimeout(handle, T_IDLE); + isc_nm_send(sendhandle, (isc_region_t *)&send_msg, + udp_cancel_read_send_cb, cbarg); + } break; case ISC_R_EOF: /* The read has been canceled */ + atomic_fetch_add(&creads, 1); isc_loopmgr_shutdown(loopmgr); break; default: @@ -719,8 +721,6 @@ udp_cancel_read_read_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_refcount_decrement(&active_creads); - atomic_fetch_add(&creads, 1); - isc_nmhandle_detach(&handle); } @@ -743,7 +743,7 @@ udp_cancel_read_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, ISC_SETUP_TEST_IMPL(udp_cancel_read) { setup_test(state); expected_cconnects = 1; - expected_creads = 2; + expected_creads = 1; return (0); }