From 6562227cc8a0732002c01cfc045129bf6080b94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 8 Sep 2022 18:24:57 +0200 Subject: [PATCH] Handle canceled read during sending data over stats channel 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. --- lib/isc/httpd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c index e4c7d71699..ac31b9a23c 100644 --- a/lib/isc/httpd.c +++ b/lib/isc/httpd.c @@ -907,13 +907,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); @@ -1200,7 +1201,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); @@ -1227,6 +1227,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;