size_t total = 0;
uint8_t tmp_data[8192] = { 0 };
uint8_t *prepared_data = &tmp_data[0];
+ isc_nmhandle_t *transphandle = NULL;
#ifdef ENABLE_HTTP_WRITE_BUFFERING
size_t max_total_write_size = 0;
#endif /* ENABLE_HTTP_WRITE_BUFFERING */
return (false);
}
+ /* We need to attach to the session->handle earlier because as an
+ * indirect result of the nghttp2_session_mem_send() the session
+ * might get closed and the handle detached. However, there is
+ * still some outgoing data to handle and we need to call it
+ * anyway if only to get the write callback passed here to get
+ * called properly. */
+ isc_nmhandle_attach(session->handle, &transphandle);
+
while (nghttp2_session_want_write(session->ngsession)) {
const uint8_t *data = NULL;
const size_t pending =
if (prepared_data != &tmp_data[0]) {
isc_mem_put(session->mctx, prepared_data, total);
}
- return (false);
+ goto failure;
} else if (session->sending == 0 && total == 0 &&
session->pending_write_data != NULL)
{
if (total == 0) {
INSIST(prepared_data == &tmp_data[0]);
/* No data returned */
- return (false);
+ goto failure;
}
send = isc_mem_get(session->mctx, sizeof(*send));
.data.length = total,
};
}
- isc_nmhandle_attach(session->handle, &send->transphandle);
+
+ send->transphandle = transphandle;
isc__nm_httpsession_attach(session, &send->session);
if (cb != NULL) {
move_pending_send_callbacks(session, send);
session->sending++;
- isc_nm_send(session->handle, &send->data, http_writecb, send);
+ isc_nm_send(transphandle, &send->data, http_writecb, send);
return (true);
+failure:
+ isc_nmhandle_detach(&transphandle);
+ return (false);
}
static void