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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user