mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-28 21:17:54 +00:00
Convert canceling UDP socket to to isc_async callback
Simplify the canceling of the UDP 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:
parent
4419848efd
commit
1baffb6ff5
@ -250,8 +250,6 @@ struct isc_nmhandle {
|
||||
};
|
||||
|
||||
typedef enum isc__netievent_type {
|
||||
netievent_udpcancel,
|
||||
|
||||
netievent_tcpaccept,
|
||||
|
||||
netievent_tlsclose,
|
||||
@ -1231,12 +1229,6 @@ isc__nm_udp_settimeout(isc_nmhandle_t *handle, uint32_t timeout);
|
||||
* Set or clear the recv timeout for the UDP socket associated with 'handle'.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__nm_async_udpcancel(isc__networker_t *worker, isc__netievent_t *ev0);
|
||||
/*%<
|
||||
* Callback handlers for asynchronous UDP events (listen, stoplisten, send).
|
||||
*/
|
||||
|
||||
void
|
||||
isc__nm_tcp_send(isc_nmhandle_t *handle, const isc_region_t *region,
|
||||
isc_nm_cb_t cb, void *cbarg);
|
||||
@ -1703,8 +1695,6 @@ NETIEVENT_SOCKET_REQ_TYPE(tlssend);
|
||||
|
||||
NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb);
|
||||
|
||||
NETIEVENT_SOCKET_HANDLE_TYPE(udpcancel);
|
||||
|
||||
NETIEVENT_SOCKET_QUOTA_TYPE(tcpaccept);
|
||||
|
||||
NETIEVENT_SOCKET_TYPE(streamdnsread);
|
||||
@ -1729,8 +1719,6 @@ NETIEVENT_SOCKET_REQ_DECL(tlssend);
|
||||
|
||||
NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb);
|
||||
|
||||
NETIEVENT_SOCKET_HANDLE_DECL(udpcancel);
|
||||
|
||||
NETIEVENT_SOCKET_QUOTA_DECL(tcpaccept);
|
||||
|
||||
NETIEVENT_SOCKET_DECL(streamdnsread);
|
||||
|
@ -439,8 +439,6 @@ process_netievent(void *arg) {
|
||||
isc__networker_t *worker = ievent->worker;
|
||||
|
||||
switch (ievent->type) {
|
||||
NETIEVENT_CASE(udpcancel);
|
||||
|
||||
NETIEVENT_CASE(tcpaccept);
|
||||
|
||||
NETIEVENT_CASE(tlssend);
|
||||
@ -483,7 +481,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) {
|
||||
NETIEVENT_SOCKET_DEF(tlsclose);
|
||||
NETIEVENT_SOCKET_DEF(tlsconnect);
|
||||
NETIEVENT_SOCKET_DEF(tlsdobio);
|
||||
NETIEVENT_SOCKET_HANDLE_DEF(udpcancel);
|
||||
|
||||
#ifdef HAVE_LIBNGHTTP2
|
||||
NETIEVENT_SOCKET_REQ_DEF(httpsend);
|
||||
|
@ -1064,36 +1064,27 @@ isc__nm_udp_shutdown(isc_nmsocket_t *sock) {
|
||||
isc__nmsocket_prep_destroy(sock);
|
||||
}
|
||||
|
||||
void
|
||||
isc__nm_udp_cancelread(isc_nmhandle_t *handle) {
|
||||
isc_nmsocket_t *sock = NULL;
|
||||
isc__netievent_udpcancel_t *ievent = NULL;
|
||||
|
||||
REQUIRE(VALID_NMHANDLE(handle));
|
||||
|
||||
sock = handle->sock;
|
||||
static void
|
||||
udp_cancelread_cb(void *arg) {
|
||||
isc_nmsocket_t *sock = arg;
|
||||
|
||||
REQUIRE(VALID_NMSOCK(sock));
|
||||
REQUIRE(sock->type == isc_nm_udpsocket);
|
||||
|
||||
ievent = isc__nm_get_netievent_udpcancel(sock->worker, sock, handle);
|
||||
|
||||
isc__nm_enqueue_ievent(sock->worker, (isc__netievent_t *)ievent);
|
||||
}
|
||||
|
||||
void
|
||||
isc__nm_async_udpcancel(isc__networker_t *worker, isc__netievent_t *ev0) {
|
||||
isc__netievent_udpcancel_t *ievent = (isc__netievent_udpcancel_t *)ev0;
|
||||
isc_nmsocket_t *sock = NULL;
|
||||
|
||||
UNUSED(worker);
|
||||
|
||||
REQUIRE(VALID_NMSOCK(ievent->sock));
|
||||
|
||||
sock = ievent->sock;
|
||||
|
||||
REQUIRE(sock->tid == isc_tid());
|
||||
REQUIRE(atomic_load(&sock->client));
|
||||
|
||||
isc__nm_failed_read_cb(sock, ISC_R_EOF, false);
|
||||
isc__nmsocket_detach(&sock);
|
||||
}
|
||||
|
||||
void
|
||||
isc__nm_udp_cancelread(isc_nmhandle_t *handle) {
|
||||
REQUIRE(VALID_NMHANDLE(handle));
|
||||
|
||||
isc_nmsocket_t *sock = handle->sock;
|
||||
|
||||
REQUIRE(VALID_NMSOCK(sock));
|
||||
REQUIRE(sock->type == isc_nm_udpsocket);
|
||||
|
||||
isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL });
|
||||
isc_async_run(sock->worker->loop, udp_cancelread_cb, sock);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user