]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add isc_nm_read_stop() and remove .reading member from ccmsg
authorOndřej Surý <ondrej@isc.org>
Thu, 8 Feb 2024 11:31:09 +0000 (12:31 +0100)
committerOndřej Surý <ondrej@isc.org>
Thu, 8 Feb 2024 16:23:39 +0000 (17:23 +0100)
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.

lib/isccc/ccmsg.c
lib/isccc/include/isccc/ccmsg.h

index 80d622da792a529870610988a190f4a8692d4bee..4c033dd975a680f599f3a094ad9928b25570e614 100644 (file)
@@ -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);
        }
index 7a20a7c2e1a7ad7483d560c318fe99e4873ac500..5120732901cfe3b6cf8da7b54b3f6941615f2ce2 100644 (file)
@@ -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