2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

Merge branch '3693-crash-when-restarting-server-with-active-statschannel-connection' into 'main'

Be more resilient when destroying the httpd requests

Closes #3693

See merge request isc-projects/bind9!7120
This commit is contained in:
Ondřej Surý
2022-11-25 16:15:08 +00:00
3 changed files with 24 additions and 6 deletions

View File

@@ -1,3 +1,8 @@
6027. [bug] Fix assertion failure in isc_http API used by
statschannel if the read callback would be called
on HTTP request that has been already closed.
[GL #3693]
6026. [cleanup] Deduplicate time unit conversion factors. 6026. [cleanup] Deduplicate time unit conversion factors.
[GL !7033] [GL !7033]

View File

@@ -52,9 +52,13 @@ Bug Fixes
10 to 100 to accomodate for some browsers that send more that 10 10 to 100 to accomodate for some browsers that send more that 10
headers by default. :gl:`#3670` headers by default. :gl:`#3670`
- Copy TLS identifier when setting up primaries for catalog member - Copy TLS identifier when setting up primaries for catalog member
zones. :gl:`#3638` zones. :gl:`#3638`
- Fix an assertion failure in the statschannel caused by reading from the HTTP
connection closed prematurely (connection error, shutdown). :gl:`#3693`
Known Issues Known Issues
~~~~~~~~~~~~ ~~~~~~~~~~~~

View File

@@ -899,14 +899,16 @@ httpd_request(isc_nmhandle_t *handle, isc_result_t eresult,
REQUIRE(VALID_HTTPD(httpd)); REQUIRE(VALID_HTTPD(httpd));
REQUIRE(httpd->handle == handle); REQUIRE(httpd->handle == handle);
REQUIRE(httpd->readhandle == handle);
isc_nm_read_stop(httpd->readhandle);
if (eresult != ISC_R_SUCCESS) { if (eresult != ISC_R_SUCCESS) {
goto close_readhandle; goto close_readhandle;
} }
REQUIRE(httpd->readhandle == handle);
REQUIRE((mgr->flags & ISC_HTTPDMGR_SHUTTINGDOWN) == 0);
isc_nm_read_stop(httpd->readhandle);
/* /*
* If we are being called from httpd_senddone(), the last HTTP request * If we are being called from httpd_senddone(), the last HTTP request
* was processed successfully, reset the last_len to 0, even if there's * was processed successfully, reset the last_len to 0, even if there's
@@ -955,6 +957,7 @@ httpd_request(isc_nmhandle_t *handle, isc_result_t eresult,
return; return;
close_readhandle: close_readhandle:
isc_nm_read_stop(httpd->readhandle);
isc_nmhandle_close(httpd->readhandle); isc_nmhandle_close(httpd->readhandle);
isc_nmhandle_detach(&httpd->readhandle); isc_nmhandle_detach(&httpd->readhandle);
} }
@@ -977,8 +980,10 @@ isc_httpdmgr_shutdown(isc_httpdmgr_t **httpdmgrp) {
httpd = ISC_LIST_HEAD(httpdmgr->running); httpd = ISC_LIST_HEAD(httpdmgr->running);
while (httpd != NULL) { while (httpd != NULL) {
isc_nm_read_stop(httpd->readhandle); if (httpd->readhandle != NULL) {
isc_nmhandle_detach(&httpd->readhandle); httpd_request(httpd->readhandle, ISC_R_SHUTTINGDOWN,
NULL, httpdmgr);
}
httpd = ISC_LIST_NEXT(httpd, link); httpd = ISC_LIST_NEXT(httpd, link);
} }
UNLOCK(&httpdmgr->lock); UNLOCK(&httpdmgr->lock);
@@ -1038,6 +1043,10 @@ httpd_senddone(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
REQUIRE(VALID_HTTPD(httpd)); REQUIRE(VALID_HTTPD(httpd));
if ((httpd->mgr->flags & ISC_HTTPDMGR_SHUTTINGDOWN) != 0) {
goto detach;
}
if (eresult == ISC_R_SUCCESS && (httpd->flags & HTTPD_CLOSE) == 0) { if (eresult == ISC_R_SUCCESS && (httpd->flags & HTTPD_CLOSE) == 0) {
/* /*
* Calling httpd_request() with region NULL restarts * Calling httpd_request() with region NULL restarts
@@ -1049,8 +1058,8 @@ httpd_senddone(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
isc_nmhandle_close(handle); isc_nmhandle_close(handle);
} }
detach:
isc_nmhandle_detach(&handle); isc_nmhandle_detach(&handle);
isc__httpd_sendreq_free(req); isc__httpd_sendreq_free(req);
} }