mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
use the correct handle when calling the read callback
when calling isc_nm_read() on an HTTP socket, the read callback was being run with the incorrect handle. this has been corrected.
This commit is contained in:
@@ -122,6 +122,7 @@ struct isc_nm_http_session {
|
|||||||
size_t nsstreams;
|
size_t nsstreams;
|
||||||
|
|
||||||
isc_nmhandle_t *handle;
|
isc_nmhandle_t *handle;
|
||||||
|
isc_nmhandle_t *client_httphandle;
|
||||||
isc_nmsocket_t *serversocket;
|
isc_nmsocket_t *serversocket;
|
||||||
isc_nmiface_t server_iface;
|
isc_nmiface_t server_iface;
|
||||||
|
|
||||||
@@ -412,11 +413,13 @@ finish_http_session(isc_nm_http_session_t *session) {
|
|||||||
if (session->closed) {
|
if (session->closed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session->handle != NULL) {
|
if (session->handle != NULL) {
|
||||||
if (!session->closed) {
|
if (!session->closed) {
|
||||||
session->closed = true;
|
session->closed = true;
|
||||||
isc_nm_cancelread(session->handle);
|
isc_nm_cancelread(session->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ISC_LIST_EMPTY(session->cstreams)) {
|
if (!ISC_LIST_EMPTY(session->cstreams)) {
|
||||||
http_cstream_t *cstream =
|
http_cstream_t *cstream =
|
||||||
ISC_LIST_HEAD(session->cstreams);
|
ISC_LIST_HEAD(session->cstreams);
|
||||||
@@ -426,7 +429,8 @@ finish_http_session(isc_nm_http_session_t *session) {
|
|||||||
ISC_LIST_DEQUEUE(session->cstreams, cstream,
|
ISC_LIST_DEQUEUE(session->cstreams, cstream,
|
||||||
link);
|
link);
|
||||||
cstream->read_cb(
|
cstream->read_cb(
|
||||||
session->handle, ISC_R_UNEXPECTED,
|
session->client_httphandle,
|
||||||
|
ISC_R_UNEXPECTED,
|
||||||
&(isc_region_t){ cstream->rbuf,
|
&(isc_region_t){ cstream->rbuf,
|
||||||
cstream->rbufsize },
|
cstream->rbufsize },
|
||||||
cstream->read_cbarg);
|
cstream->read_cbarg);
|
||||||
@@ -437,6 +441,10 @@ finish_http_session(isc_nm_http_session_t *session) {
|
|||||||
isc_nmhandle_detach(&session->handle);
|
isc_nmhandle_detach(&session->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (session->client_httphandle != NULL) {
|
||||||
|
isc_nmhandle_detach(&session->client_httphandle);
|
||||||
|
}
|
||||||
|
|
||||||
INSIST(ISC_LIST_EMPTY(session->cstreams));
|
INSIST(ISC_LIST_EMPTY(session->cstreams));
|
||||||
|
|
||||||
/* detach from server socket */
|
/* detach from server socket */
|
||||||
@@ -1049,15 +1057,24 @@ get_http_cstream(isc_nmsocket_t *sock, http_cstream_t **streamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
http_call_connect_cb(isc_nmsocket_t *sock, isc_result_t result) {
|
http_call_connect_cb(isc_nmsocket_t *sock, isc_nm_http_session_t *session,
|
||||||
|
isc_result_t result) {
|
||||||
isc__nm_uvreq_t *req = NULL;
|
isc__nm_uvreq_t *req = NULL;
|
||||||
|
isc_nmhandle_t *httphandle = isc__nmhandle_get(sock, &sock->peer,
|
||||||
|
&sock->iface->addr);
|
||||||
|
|
||||||
REQUIRE(sock->connect_cb != NULL);
|
REQUIRE(sock->connect_cb != NULL);
|
||||||
|
|
||||||
req = isc__nm_uvreq_get(sock->mgr, sock);
|
req = isc__nm_uvreq_get(sock->mgr, sock);
|
||||||
req->cb.connect = sock->connect_cb;
|
req->cb.connect = sock->connect_cb;
|
||||||
req->cbarg = sock->connect_cbarg;
|
req->cbarg = sock->connect_cbarg;
|
||||||
req->handle = isc__nmhandle_get(sock, &sock->peer, &sock->iface->addr);
|
if (session != NULL) {
|
||||||
|
session->client_httphandle = httphandle;
|
||||||
|
req->handle = NULL;
|
||||||
|
isc_nmhandle_attach(httphandle, &req->handle);
|
||||||
|
} else {
|
||||||
|
req->handle = httphandle;
|
||||||
|
}
|
||||||
|
|
||||||
isc__nmsocket_clearcb(sock);
|
isc__nmsocket_clearcb(sock);
|
||||||
isc__nm_connectcb(sock, req, result, true);
|
isc__nm_connectcb(sock, req, result, true);
|
||||||
@@ -1066,8 +1083,8 @@ http_call_connect_cb(isc_nmsocket_t *sock, isc_result_t result) {
|
|||||||
static void
|
static void
|
||||||
transport_connect_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
|
transport_connect_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
|
||||||
isc_nmsocket_t *http_sock = (isc_nmsocket_t *)cbarg;
|
isc_nmsocket_t *http_sock = (isc_nmsocket_t *)cbarg;
|
||||||
isc_nm_http_session_t *session = NULL;
|
|
||||||
isc_nmsocket_t *transp_sock = NULL;
|
isc_nmsocket_t *transp_sock = NULL;
|
||||||
|
isc_nm_http_session_t *session = NULL;
|
||||||
http_cstream_t *cstream = NULL;
|
http_cstream_t *cstream = NULL;
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
|
|
||||||
@@ -1134,13 +1151,15 @@ transport_connect_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
http_transpost_tcp_nodelay(handle);
|
http_transpost_tcp_nodelay(handle);
|
||||||
http_call_connect_cb(http_sock, result);
|
|
||||||
|
http_call_connect_cb(http_sock, session, result);
|
||||||
|
|
||||||
http_do_bio(session, NULL, NULL, NULL);
|
http_do_bio(session, NULL, NULL, NULL);
|
||||||
isc__nmsocket_detach(&http_sock);
|
isc__nmsocket_detach(&http_sock);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
http_call_connect_cb(http_sock, result);
|
http_call_connect_cb(http_sock, session, result);
|
||||||
|
|
||||||
if (http_sock->h2.connect.uri != NULL) {
|
if (http_sock->h2.connect.uri != NULL) {
|
||||||
isc_mem_free(mctx, http_sock->h2.connect.uri);
|
isc_mem_free(mctx, http_sock->h2.connect.uri);
|
||||||
@@ -2361,7 +2380,7 @@ failed_read_cb(isc_result_t result, isc_nm_http_session_t *session) {
|
|||||||
cstream = ISC_LIST_HEAD(session->cstreams);
|
cstream = ISC_LIST_HEAD(session->cstreams);
|
||||||
while (cstream != NULL) {
|
while (cstream != NULL) {
|
||||||
http_cstream_t *next = ISC_LIST_NEXT(cstream, link);
|
http_cstream_t *next = ISC_LIST_NEXT(cstream, link);
|
||||||
cstream->read_cb(session->handle, result,
|
cstream->read_cb(session->client_httphandle, result,
|
||||||
&(isc_region_t){ cstream->rbuf,
|
&(isc_region_t){ cstream->rbuf,
|
||||||
cstream->rbufsize },
|
cstream->rbufsize },
|
||||||
cstream->read_cbarg);
|
cstream->read_cbarg);
|
||||||
|
@@ -581,20 +581,13 @@ timeout_retry_cb(isc_nmhandle_t *handle, isc_result_t eresult,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
isc_nmhandle_detach(&handle);
|
||||||
* XXX: We should be attaching to a readhandle in
|
|
||||||
* timeout_request_cb() and detaching it here, but we
|
|
||||||
* don't do this because the handle passed to this function
|
|
||||||
* is for the tcpsocket, not the httpsocket. This is a
|
|
||||||
* bug.
|
|
||||||
*/
|
|
||||||
/* isc_nmhandle_detach(&handle); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
timeout_request_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
timeout_request_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
||||||
isc_nmhandle_t *sendhandle = NULL;
|
isc_nmhandle_t *sendhandle = NULL;
|
||||||
/* isc_nmhandle_t *readhandle = NULL; */
|
isc_nmhandle_t *readhandle = NULL;
|
||||||
|
|
||||||
REQUIRE(VALID_NMHANDLE(handle));
|
REQUIRE(VALID_NMHANDLE(handle));
|
||||||
|
|
||||||
@@ -608,7 +601,7 @@ timeout_request_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
|||||||
.length = send_msg.len },
|
.length = send_msg.len },
|
||||||
timeout_query_sent_cb, arg);
|
timeout_query_sent_cb, arg);
|
||||||
|
|
||||||
/* isc_nmhandle_attach(handle, &readhandle); */
|
isc_nmhandle_attach(handle, &readhandle);
|
||||||
isc_nm_read(handle, timeout_retry_cb, NULL);
|
isc_nm_read(handle, timeout_retry_cb, NULL);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user