size_t nsstreams;
isc_nmhandle_t *handle;
+ isc_nmhandle_t *client_httphandle;
isc_nmsocket_t *serversocket;
isc_nmiface_t server_iface;
if (session->closed) {
return;
}
+
if (session->handle != NULL) {
if (!session->closed) {
session->closed = true;
isc_nm_cancelread(session->handle);
}
+
if (!ISC_LIST_EMPTY(session->cstreams)) {
http_cstream_t *cstream =
ISC_LIST_HEAD(session->cstreams);
ISC_LIST_DEQUEUE(session->cstreams, cstream,
link);
cstream->read_cb(
- session->handle, ISC_R_UNEXPECTED,
+ session->client_httphandle,
+ ISC_R_UNEXPECTED,
&(isc_region_t){ cstream->rbuf,
cstream->rbufsize },
cstream->read_cbarg);
isc_nmhandle_detach(&session->handle);
}
+ if (session->client_httphandle != NULL) {
+ isc_nmhandle_detach(&session->client_httphandle);
+ }
+
INSIST(ISC_LIST_EMPTY(session->cstreams));
/* detach from server socket */
}
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_nmhandle_t *httphandle = isc__nmhandle_get(sock, &sock->peer,
+ &sock->iface->addr);
REQUIRE(sock->connect_cb != NULL);
req = isc__nm_uvreq_get(sock->mgr, sock);
req->cb.connect = sock->connect_cb;
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__nm_connectcb(sock, req, result, true);
static void
transport_connect_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
isc_nmsocket_t *http_sock = (isc_nmsocket_t *)cbarg;
- isc_nm_http_session_t *session = NULL;
isc_nmsocket_t *transp_sock = NULL;
+ isc_nm_http_session_t *session = NULL;
http_cstream_t *cstream = NULL;
isc_mem_t *mctx = NULL;
}
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);
isc__nmsocket_detach(&http_sock);
return;
error:
- http_call_connect_cb(http_sock, result);
+ http_call_connect_cb(http_sock, session, result);
if (http_sock->h2.connect.uri != NULL) {
isc_mem_free(mctx, http_sock->h2.connect.uri);
cstream = ISC_LIST_HEAD(session->cstreams);
while (cstream != NULL) {
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,
cstream->rbufsize },
cstream->read_cbarg);
return;
}
- /*
- * 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); */
+ isc_nmhandle_detach(&handle);
}
static void
timeout_request_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
isc_nmhandle_t *sendhandle = NULL;
- /* isc_nmhandle_t *readhandle = NULL; */
+ isc_nmhandle_t *readhandle = NULL;
REQUIRE(VALID_NMHANDLE(handle));
.length = send_msg.len },
timeout_query_sent_cb, arg);
- /* isc_nmhandle_attach(handle, &readhandle); */
+ isc_nmhandle_attach(handle, &readhandle);
isc_nm_read(handle, timeout_retry_cb, NULL);
return;