From d6041e5d45329efcd060e2252eb679cc0cf5e101 Mon Sep 17 00:00:00 2001 From: Artem Boldariev Date: Sat, 2 Jul 2022 02:20:39 +0300 Subject: [PATCH] *_noresponse, tlsdns_listen_noalpn: csends == 1 is not guaranteed This commit removes an assertion from the unit test which cannot be guaranteed. According to the test, exactly one client send must succeed. However, it cannot really be guaranteed, as do not start to read data in the accept callback on the server nor attach to the accepted handle. Thus, we can expect the connection to be closed soon after we have returned from the callback. Interestingly enough, the test would pass just fine on TCP because: a) there are fewer layers involved and thus there is less processing; b) it is possible for the data to be sent and end up in an internal OS socket buffer without being touched by an application's code on the server. In such a case the client's write callback still would be called successfully; There is a chance for the test to succeed over TLS as well (as it happily did before), but as the code has been changed to close unused connections as soon as possible, the chance is far slimmer now. What can be guaranteed is: * cconnects == 1 (number client connections equals 1); * saccepts == 1 (number of accepted connections equals 1). (cherry picked from commit 0f9b6a7bc18856ffd087ec23bb97f1ea3a5964b6) --- tests/isc/netmgr_test.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/isc/netmgr_test.c b/tests/isc/netmgr_test.c index f407a3647b..94e4bf792a 100644 --- a/tests/isc/netmgr_test.c +++ b/tests/isc/netmgr_test.c @@ -386,9 +386,12 @@ noop_recv_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region, static unsigned int noop_accept_cb(isc_nmhandle_t *handle, unsigned int result, void *cbarg) { UNUSED(handle); - UNUSED(result); UNUSED(cbarg); + if (result == ISC_R_SUCCESS) { + (void)atomic_fetch_add(&saccepts, 1); + } + return (0); } @@ -1209,7 +1212,7 @@ stream_noresponse(void **state __attribute__((unused))) { stream_connect(connect_connect_cb, NULL, T_CONNECT, 0); WAIT_FOR_EQ(cconnects, 1); - WAIT_FOR_EQ(csends, 1); + WAIT_FOR_EQ(saccepts, 1); isc_nm_stoplistening(listen_sock); isc_nmsocket_close(&listen_sock); @@ -1223,7 +1226,7 @@ stream_noresponse(void **state __attribute__((unused))) { X(ssends); atomic_assert_int_eq(cconnects, 1); - atomic_assert_int_eq(csends, 1); + atomic_assert_int_eq(saccepts, 1); atomic_assert_int_eq(creads, 0); atomic_assert_int_eq(sreads, 0); atomic_assert_int_eq(ssends, 0); @@ -1728,7 +1731,7 @@ ISC_RUN_TEST_IMPL(tcpdns_noresponse) { connect_connect_cb, NULL, T_CONNECT, 0); WAIT_FOR_EQ(cconnects, 1); - WAIT_FOR_EQ(csends, 1); + WAIT_FOR_EQ(saccepts, 1); isc_nm_stoplistening(listen_sock); isc_nmsocket_close(&listen_sock); @@ -1742,7 +1745,7 @@ ISC_RUN_TEST_IMPL(tcpdns_noresponse) { X(ssends); atomic_assert_int_eq(cconnects, 1); - atomic_assert_int_eq(csends, 1); + atomic_assert_int_eq(saccepts, 1); atomic_assert_int_eq(creads, 0); atomic_assert_int_eq(sreads, 0); atomic_assert_int_eq(ssends, 0); @@ -2279,7 +2282,7 @@ ISC_RUN_TEST_IMPL(tlsdns_noresponse) { tcp_connect_tlsctx, tcp_tlsctx_client_sess_cache); WAIT_FOR_EQ(cconnects, 1); - WAIT_FOR_EQ(csends, 1); + WAIT_FOR_EQ(saccepts, 1); isc_nm_stoplistening(listen_sock); isc_nmsocket_close(&listen_sock); @@ -2293,7 +2296,7 @@ ISC_RUN_TEST_IMPL(tlsdns_noresponse) { X(ssends); atomic_assert_int_eq(cconnects, 1); - atomic_assert_int_eq(csends, 1); + atomic_assert_int_eq(saccepts, 1); atomic_assert_int_eq(creads, 0); atomic_assert_int_eq(sreads, 0); atomic_assert_int_eq(ssends, 0); @@ -2743,7 +2746,6 @@ ISC_RUN_TEST_IMPL(tlsdns_listen_noalpn) { WAIT_FOR_EQ(saccepts, 1); WAIT_FOR_EQ(cconnects, 1); - WAIT_FOR_EQ(csends, 1); isc_nm_stoplistening(listen_sock); isc_nmsocket_close(&listen_sock); @@ -2758,7 +2760,6 @@ ISC_RUN_TEST_IMPL(tlsdns_listen_noalpn) { atomic_assert_int_eq(saccepts, 1); atomic_assert_int_eq(cconnects, 1); - atomic_assert_int_eq(csends, 1); atomic_assert_int_eq(creads, 0); atomic_assert_int_eq(sreads, 0); atomic_assert_int_eq(ssends, 0);