]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Handle canceled read during sending data over stats channel
authorOndřej Surý <ondrej@isc.org>
Thu, 8 Sep 2022 16:24:57 +0000 (18:24 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 15 Sep 2022 08:58:09 +0000 (10:58 +0200)
An assertion failure would be triggered when the TCP connection
is canceled during sending the data back to the client.

Don't require the state to be `RECV` on non successful read to
gracefully handle canceled TCP connection during the SEND state of the
HTTPD channel.

(cherry picked from commit 6562227cc8a0732002c01cfc045129bf6080b94c)

lib/isc/httpd.c

index a701fb2a8423d03d504ebf7362f11553ea25d990..134806bea9859c1882797e63fd263a69cd47b34c 100644 (file)
@@ -904,13 +904,14 @@ httpd_request(isc_nmhandle_t *handle, isc_result_t eresult,
 
        httpd = isc_nmhandle_getdata(handle);
 
-       REQUIRE(httpd->state == RECV);
        REQUIRE(httpd->handle == handle);
 
        if (eresult != ISC_R_SUCCESS) {
                goto cleanup_readhandle;
        }
 
+       REQUIRE(httpd->state == RECV);
+
        result = process_request(
                httpd, region == NULL ? &(isc_region_t){ NULL, 0 } : region,
                &buflen);
@@ -1195,7 +1196,6 @@ httpd_senddone(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
        isc_httpd_t *httpd = (isc_httpd_t *)arg;
 
        REQUIRE(VALID_HTTPD(httpd));
-       REQUIRE(httpd->state == SEND);
        REQUIRE(httpd->handle == handle);
 
        isc_buffer_free(&httpd->sendbuffer);
@@ -1222,6 +1222,8 @@ httpd_senddone(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
                goto cleanup_readhandle;
        }
 
+       REQUIRE(httpd->state == SEND);
+
        httpd->state = RECV;
        httpd->sendhandle = NULL;