mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Fix isc_nm_httpconnect to check for shuttindown condition
The isc_nm_httpconnect() would succeed even if the netmgr would be already shuttingdown. This has been fixed and the unit test has been updated to cope with fact that the handle would be NULL when isc_nm_httpconnect() returns with an error.
This commit is contained in:
@@ -1464,6 +1464,11 @@ isc_nm_httpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
|
|||||||
REQUIRE(uri != NULL);
|
REQUIRE(uri != NULL);
|
||||||
REQUIRE(*uri != '\0');
|
REQUIRE(*uri != '\0');
|
||||||
|
|
||||||
|
if (isc__nm_closing(worker)) {
|
||||||
|
cb(NULL, ISC_R_SHUTTINGDOWN, cbarg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (local == NULL) {
|
if (local == NULL) {
|
||||||
isc_sockaddr_anyofpf(&local_interface, peer->type.sa.sa_family);
|
isc_sockaddr_anyofpf(&local_interface, peer->type.sa.sa_family);
|
||||||
local = &local_interface;
|
local = &local_interface;
|
||||||
|
@@ -134,8 +134,6 @@ static void
|
|||||||
connect_send_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
connect_send_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
||||||
csdata_t data;
|
csdata_t data;
|
||||||
|
|
||||||
REQUIRE(VALID_NMHANDLE(handle));
|
|
||||||
|
|
||||||
(void)atomic_fetch_sub(&active_cconnects, 1);
|
(void)atomic_fetch_sub(&active_cconnects, 1);
|
||||||
memmove(&data, arg, sizeof(data));
|
memmove(&data, arg, sizeof(data));
|
||||||
isc_mem_put(data.mctx, arg, sizeof(data));
|
isc_mem_put(data.mctx, arg, sizeof(data));
|
||||||
@@ -143,6 +141,8 @@ connect_send_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
REQUIRE(VALID_NMHANDLE(handle));
|
||||||
|
|
||||||
result = isc__nm_http_request(handle, &data.region, data.reply_cb,
|
result = isc__nm_http_request(handle, &data.region, data.reply_cb,
|
||||||
data.cb_arg);
|
data.cb_arg);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
@@ -675,39 +675,38 @@ doh_connect_thread(void *arg);
|
|||||||
static void
|
static void
|
||||||
doh_receive_send_reply_cb(isc_nmhandle_t *handle, isc_result_t eresult,
|
doh_receive_send_reply_cb(isc_nmhandle_t *handle, isc_result_t eresult,
|
||||||
isc_region_t *region, void *cbarg) {
|
isc_region_t *region, void *cbarg) {
|
||||||
isc_nmhandle_t *thandle = NULL;
|
|
||||||
isc_nm_t *connect_nm = (isc_nm_t *)cbarg;
|
isc_nm_t *connect_nm = (isc_nm_t *)cbarg;
|
||||||
|
|
||||||
|
if (eresult != ISC_R_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert_non_null(handle);
|
assert_non_null(handle);
|
||||||
UNUSED(region);
|
UNUSED(region);
|
||||||
|
|
||||||
isc_nmhandle_attach(handle, &thandle);
|
int_fast64_t sends = atomic_fetch_sub(&nsends, 1);
|
||||||
if (eresult == ISC_R_SUCCESS) {
|
atomic_fetch_add(&csends, 1);
|
||||||
int_fast64_t sends = atomic_fetch_sub(&nsends, 1);
|
atomic_fetch_add(&creads, 1);
|
||||||
atomic_fetch_add(&csends, 1);
|
if (sends > 0 && connect_nm != NULL) {
|
||||||
atomic_fetch_add(&creads, 1);
|
size_t i;
|
||||||
if (sends > 0 && connect_nm != NULL) {
|
for (i = 0; i < NWRITES / 2; i++) {
|
||||||
size_t i;
|
eresult = isc__nm_http_request(
|
||||||
for (i = 0; i < NWRITES / 2; i++) {
|
handle,
|
||||||
eresult = isc__nm_http_request(
|
&(isc_region_t){
|
||||||
handle,
|
.base = (uint8_t *)send_msg.base,
|
||||||
&(isc_region_t){
|
.length = send_msg.len },
|
||||||
.base = (uint8_t *)send_msg.base,
|
doh_receive_send_reply_cb, NULL);
|
||||||
.length = send_msg.len },
|
if (eresult == ISC_R_CANCELED) {
|
||||||
doh_receive_send_reply_cb, NULL);
|
break;
|
||||||
if (eresult == ISC_R_CANCELED) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
assert_true(eresult == ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
assert_true(eresult == ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
isc_job_run(loopmgr, doh_connect_thread, connect_nm);
|
isc_job_run(loopmgr, doh_connect_thread, connect_nm);
|
||||||
}
|
}
|
||||||
if (sends <= 0) {
|
if (sends <= 0) {
|
||||||
isc_loopmgr_shutdown(loopmgr);
|
isc_loopmgr_shutdown(loopmgr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
isc_nmhandle_detach(&thandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user