2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

Convert canceling StreamDNS socket to to isc_async callback

Simplify the canceling of the StreamDNS 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:34:12 +01:00
parent 2185dc75f0
commit 7ddc49d66a
3 changed files with 11 additions and 31 deletions

View File

@@ -250,8 +250,6 @@ struct isc_nmhandle {
}; };
typedef enum isc__netievent_type { typedef enum isc__netievent_type {
netievent_streamdnscancel,
netievent_settlsctx, netievent_settlsctx,
netievent_sockstop, /* for multilayer sockets */ netievent_sockstop, /* for multilayer sockets */
} isc__netievent_type; } isc__netievent_type;
@@ -1467,9 +1465,6 @@ isc__nm_streamdns_stoplistening(isc_nmsocket_t *sock);
void void
isc__nm_streamdns_cleanup_data(isc_nmsocket_t *sock); isc__nm_streamdns_cleanup_data(isc_nmsocket_t *sock);
void
isc__nm_async_streamdnscancel(isc__networker_t *worker, isc__netievent_t *ev0);
void void
isc__nm_streamdns_cancelread(isc_nmhandle_t *handle); isc__nm_streamdns_cancelread(isc_nmhandle_t *handle);
@@ -1634,8 +1629,6 @@ isc__nmsocket_stop(isc_nmsocket_t *listener);
NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb); NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb);
NETIEVENT_SOCKET_HANDLE_TYPE(streamdnscancel);
NETIEVENT_SOCKET_TLSCTX_TYPE(settlsctx); NETIEVENT_SOCKET_TLSCTX_TYPE(settlsctx);
NETIEVENT_SOCKET_TYPE(sockstop); NETIEVENT_SOCKET_TYPE(sockstop);
@@ -1643,8 +1636,6 @@ NETIEVENT_SOCKET_TYPE(sockstop);
NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb); NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb);
NETIEVENT_SOCKET_HANDLE_DECL(streamdnscancel);
NETIEVENT_SOCKET_TLSCTX_DECL(settlsctx); NETIEVENT_SOCKET_TLSCTX_DECL(settlsctx);
NETIEVENT_SOCKET_DECL(sockstop); NETIEVENT_SOCKET_DECL(sockstop);

View File

@@ -439,8 +439,6 @@ process_netievent(void *arg) {
isc__networker_t *worker = ievent->worker; isc__networker_t *worker = ievent->worker;
switch (ievent->type) { switch (ievent->type) {
NETIEVENT_CASE(streamdnscancel);
NETIEVENT_CASE(settlsctx); NETIEVENT_CASE(settlsctx);
NETIEVENT_CASE(sockstop); NETIEVENT_CASE(sockstop);
default: default:
@@ -467,8 +465,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) {
isc__networker_unref(worker); isc__networker_unref(worker);
} }
NETIEVENT_SOCKET_HANDLE_DEF(streamdnscancel);
NETIEVENT_SOCKET_TLSCTX_DEF(settlsctx); NETIEVENT_SOCKET_TLSCTX_DEF(settlsctx);
NETIEVENT_SOCKET_DEF(sockstop); NETIEVENT_SOCKET_DEF(sockstop);

View File

@@ -962,6 +962,15 @@ isc__nm_streamdns_stoplistening(isc_nmsocket_t *sock) {
isc__nmsocket_stop(sock); isc__nmsocket_stop(sock);
} }
static void
streamdns_cancelread_cb(void *arg) {
isc_nmsocket_t *sock = arg;
REQUIRE(VALID_NMSOCK(sock));
streamdns_failed_read_cb(sock, ISC_R_EOF, false);
isc__nmsocket_detach(&sock);
}
void void
isc__nm_streamdns_cancelread(isc_nmhandle_t *handle) { isc__nm_streamdns_cancelread(isc_nmhandle_t *handle) {
isc_nmsocket_t *sock = NULL; isc_nmsocket_t *sock = NULL;
@@ -972,24 +981,8 @@ isc__nm_streamdns_cancelread(isc_nmhandle_t *handle) {
sock = handle->sock; sock = handle->sock;
isc__netievent_streamdnscancel_t *ievent = isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL });
isc__nm_get_netievent_streamdnscancel(sock->worker, isc_async_run(sock->worker->loop, streamdns_cancelread_cb, sock);
handle->sock, handle);
isc__nm_enqueue_ievent(sock->worker, (isc__netievent_t *)ievent);
}
void
isc__nm_async_streamdnscancel(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_streamdnscancel_t *ievent =
(isc__netievent_streamdnscancel_t *)ev0;
isc_nmsocket_t *sock = ievent->sock;
UNUSED(worker);
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_tid());
streamdns_failed_read_cb(sock, ISC_R_EOF, false);
} }
void void