From: Ondřej Surý Date: Thu, 8 Feb 2024 11:31:09 +0000 (+0100) Subject: Add isc_nm_read_stop() and remove .reading member from ccmsg X-Git-Tag: v9.19.22~49^2~2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=88a14985dbd7093df73c46e00a74539382e79e16;p=thirdparty%2Fbind9.git Add isc_nm_read_stop() and remove .reading member from ccmsg We need to stop reading when calling isc_ccmsg_disconnect() as the reading handle doesn't have to be last because sending might be in progress. After that, we can safely remove .reading member because the reading would not be called after the disconnect has been called. The ccmsg_senddone() should also not call the recv callback if the sending failed, that's the job of the caller's send callback - in fact it already does that, so the code in ccmsg_senddone() was superfluous. --- diff --git a/lib/isccc/ccmsg.c b/lib/isccc/ccmsg.c index 80d622da792..4c033dd975a 100644 --- a/lib/isccc/ccmsg.c +++ b/lib/isccc/ccmsg.c @@ -102,10 +102,7 @@ recv_data(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region, done: isc_nm_read_stop(handle); - if (ccmsg->reading) { - ccmsg->reading = false; - ccmsg->recv_cb(handle, eresult, ccmsg->recv_cbarg); - } + ccmsg->recv_cb(handle, eresult, ccmsg->recv_cbarg); return; } @@ -145,7 +142,6 @@ isccc_ccmsg_readmessage(isccc_ccmsg_t *ccmsg, isc_nm_cb_t cb, void *cbarg) { ccmsg->recv_cbarg = cbarg; ccmsg->length_received = false; - ccmsg->reading = true; isc_nm_read(ccmsg->handle, recv_data, ccmsg); } @@ -159,10 +155,6 @@ ccmsg_senddone(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) { ccmsg->send_cb(handle, eresult, ccmsg->send_cbarg); ccmsg->send_cb = NULL; - if (eresult != ISC_R_SUCCESS && ccmsg->reading) { - recv_data(handle, eresult, NULL, ccmsg); - } - isc_nmhandle_detach(&handle); } @@ -184,6 +176,7 @@ isccc_ccmsg_disconnect(isccc_ccmsg_t *ccmsg) { REQUIRE(VALID_CCMSG(ccmsg)); if (ccmsg->handle != NULL) { + isc_nm_read_stop(ccmsg->handle); isc_nmhandle_close(ccmsg->handle); isc_nmhandle_detach(&ccmsg->handle); } diff --git a/lib/isccc/include/isccc/ccmsg.h b/lib/isccc/include/isccc/ccmsg.h index 7a20a7c2e1a..5120732901c 100644 --- a/lib/isccc/include/isccc/ccmsg.h +++ b/lib/isccc/include/isccc/ccmsg.h @@ -54,7 +54,6 @@ typedef struct isccc_ccmsg { void *recv_cbarg; isc_nm_cb_t send_cb; void *send_cbarg; - bool reading; } isccc_ccmsg_t; ISC_LANG_BEGINDECLS