2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 16:15:27 +00:00

Convert sending on the DoH socket to to isc_async callback

Simplify the sending on the DoH socket by using the isc_async API
from the loopmgr instead of using the asychronous netievent mechanism in
the netmgr.
This commit is contained in:
Ondřej Surý
2023-03-23 23:00:21 +01:00
parent a321d3f419
commit 115160de73
3 changed files with 12 additions and 23 deletions

View File

@@ -2157,11 +2157,13 @@ error:
return (0);
}
static void
http_send_cb(void *arg);
void
isc__nm_http_send(isc_nmhandle_t *handle, const isc_region_t *region,
isc_nm_cb_t cb, void *cbarg) {
isc_nmsocket_t *sock = NULL;
isc__netievent_httpsend_t *ievent = NULL;
isc__nm_uvreq_t *uvreq = NULL;
REQUIRE(VALID_NMHANDLE(handle));
@@ -2179,8 +2181,7 @@ isc__nm_http_send(isc_nmhandle_t *handle, const isc_region_t *region,
uvreq->uvbuf.base = (char *)region->base;
uvreq->uvbuf.len = region->length;
ievent = isc__nm_get_netievent_httpsend(sock->worker, sock, uvreq);
isc__nm_enqueue_ievent(sock->worker, (isc__netievent_t *)ievent);
isc_async_run(sock->worker->loop, http_send_cb, uvreq);
}
static void
@@ -2270,26 +2271,22 @@ server_httpsend(isc_nmhandle_t *handle, isc_nmsocket_t *sock,
isc__nm_uvreq_put(&req, sock);
}
void
isc__nm_async_httpsend(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_httpsend_t *ievent = (isc__netievent_httpsend_t *)ev0;
isc_nmsocket_t *sock = ievent->sock;
isc__nm_uvreq_t *req = ievent->req;
isc_nmhandle_t *handle = NULL;
isc_nm_http_session_t *session = NULL;
static void
http_send_cb(void *arg) {
isc__nm_uvreq_t *req = arg;
UNUSED(worker);
REQUIRE(VALID_UVREQ(req));
isc_nmsocket_t *sock = req->sock;
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(VALID_UVREQ(req));
REQUIRE(VALID_HTTP2_SESSION(sock->h2.session));
ievent->req = NULL;
handle = req->handle;
isc_nmhandle_t *handle = req->handle;
REQUIRE(VALID_NMHANDLE(handle));
session = sock->h2.session;
isc_nm_http_session_t *session = sock->h2.session;
if (session != NULL && session->client) {
client_httpsend(handle, sock, req);
} else {

View File

@@ -250,7 +250,6 @@ struct isc_nmhandle {
};
typedef enum isc__netievent_type {
netievent_httpsend,
netievent_httpendpoints,
netievent_streamdnsread,
@@ -1427,9 +1426,6 @@ isc__nm_http_set_maxage(isc_nmhandle_t *handle, const uint32_t ttl);
const char *
isc__nm_http_verify_tls_peer_result_string(const isc_nmhandle_t *handle);
void
isc__nm_async_httpsend(isc__networker_t *worker, isc__netievent_t *ev0);
void
isc__nm_async_httpendpoints(isc__networker_t *worker, isc__netievent_t *ev0);
@@ -1646,7 +1642,6 @@ isc__nmsocket_stop(isc_nmsocket_t *listener);
*/
#ifdef HAVE_LIBNGHTTP2
NETIEVENT_SOCKET_REQ_TYPE(httpsend);
NETIEVENT_SOCKET_HTTP_EPS_TYPE(httpendpoints);
#endif /* HAVE_LIBNGHTTP2 */
@@ -1661,7 +1656,6 @@ NETIEVENT_SOCKET_TYPE(sockstop);
/* Now declared the helper functions */
#ifdef HAVE_LIBNGHTTP2
NETIEVENT_SOCKET_REQ_DECL(httpsend);
NETIEVENT_SOCKET_HTTP_EPS_DECL(httpendpoints);
#endif /* HAVE_LIBNGHTTP2 */

View File

@@ -440,7 +440,6 @@ process_netievent(void *arg) {
switch (ievent->type) {
#if HAVE_LIBNGHTTP2
NETIEVENT_CASE(httpsend);
NETIEVENT_CASE(httpendpoints);
#endif
NETIEVENT_CASE(streamdnsread);
@@ -473,7 +472,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) {
}
#ifdef HAVE_LIBNGHTTP2
NETIEVENT_SOCKET_REQ_DEF(httpsend);
NETIEVENT_SOCKET_HTTP_EPS_DEF(httpendpoints);
#endif /* HAVE_LIBNGHTTP2 */