mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 08:05:21 +00:00
Convert reading from StreamDNS socket to to isc_async callback
Simplify the reading from 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:
@@ -250,7 +250,6 @@ struct isc_nmhandle {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef enum isc__netievent_type {
|
typedef enum isc__netievent_type {
|
||||||
netievent_streamdnsread,
|
|
||||||
netievent_streamdnscancel,
|
netievent_streamdnscancel,
|
||||||
|
|
||||||
netievent_settlsctx,
|
netievent_settlsctx,
|
||||||
@@ -1451,9 +1450,6 @@ isc__nm_http_set_max_streams(isc_nmsocket_t *listener,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
|
||||||
isc__nm_async_streamdnsread(isc__networker_t *worker, isc__netievent_t *ev0);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb,
|
isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb,
|
||||||
void *cbarg);
|
void *cbarg);
|
||||||
@@ -1638,7 +1634,6 @@ isc__nmsocket_stop(isc_nmsocket_t *listener);
|
|||||||
|
|
||||||
NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb);
|
NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb);
|
||||||
|
|
||||||
NETIEVENT_SOCKET_TYPE(streamdnsread);
|
|
||||||
NETIEVENT_SOCKET_HANDLE_TYPE(streamdnscancel);
|
NETIEVENT_SOCKET_HANDLE_TYPE(streamdnscancel);
|
||||||
|
|
||||||
NETIEVENT_SOCKET_TLSCTX_TYPE(settlsctx);
|
NETIEVENT_SOCKET_TLSCTX_TYPE(settlsctx);
|
||||||
@@ -1648,7 +1643,6 @@ NETIEVENT_SOCKET_TYPE(sockstop);
|
|||||||
|
|
||||||
NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb);
|
NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb);
|
||||||
|
|
||||||
NETIEVENT_SOCKET_DECL(streamdnsread);
|
|
||||||
NETIEVENT_SOCKET_HANDLE_DECL(streamdnscancel);
|
NETIEVENT_SOCKET_HANDLE_DECL(streamdnscancel);
|
||||||
|
|
||||||
NETIEVENT_SOCKET_TLSCTX_DECL(settlsctx);
|
NETIEVENT_SOCKET_TLSCTX_DECL(settlsctx);
|
||||||
|
@@ -439,7 +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(streamdnsread);
|
|
||||||
NETIEVENT_CASE(streamdnscancel);
|
NETIEVENT_CASE(streamdnscancel);
|
||||||
|
|
||||||
NETIEVENT_CASE(settlsctx);
|
NETIEVENT_CASE(settlsctx);
|
||||||
@@ -468,7 +467,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) {
|
|||||||
isc__networker_unref(worker);
|
isc__networker_unref(worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
NETIEVENT_SOCKET_DEF(streamdnsread);
|
|
||||||
NETIEVENT_SOCKET_HANDLE_DEF(streamdnscancel);
|
NETIEVENT_SOCKET_HANDLE_DEF(streamdnscancel);
|
||||||
|
|
||||||
NETIEVENT_SOCKET_TLSCTX_DEF(settlsctx);
|
NETIEVENT_SOCKET_TLSCTX_DEF(settlsctx);
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <isc/async.h>
|
||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
@@ -797,26 +798,26 @@ isc__nm_streamdns_cleanup_data(isc_nmsocket_t *sock) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
isc__nm_async_streamdnsread(isc__networker_t *worker, isc__netievent_t *ev0) {
|
streamdns_read_cb(void *arg) {
|
||||||
isc__netievent_streamdnsread_t *ievent =
|
isc_nmsocket_t *sock = arg;
|
||||||
(isc__netievent_streamdnsread_t *)ev0;
|
|
||||||
isc_nmsocket_t *sock = ievent->sock;
|
|
||||||
|
|
||||||
|
REQUIRE(VALID_NMSOCK(sock));
|
||||||
REQUIRE(sock->tid == isc_tid());
|
REQUIRE(sock->tid == isc_tid());
|
||||||
UNUSED(worker);
|
|
||||||
|
|
||||||
if (streamdns_closing(sock)) {
|
if (streamdns_closing(sock)) {
|
||||||
streamdns_failed_read_cb(sock, ISC_R_CANCELED, false);
|
streamdns_failed_read_cb(sock, ISC_R_CANCELED, false);
|
||||||
return;
|
goto detach;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sock->streamdns.reading) {
|
if (sock->streamdns.reading) {
|
||||||
return;
|
goto detach;
|
||||||
}
|
}
|
||||||
|
|
||||||
INSIST(VALID_NMHANDLE(sock->outerhandle));
|
INSIST(VALID_NMHANDLE(sock->outerhandle));
|
||||||
streamdns_handle_incoming_data(sock, sock->outerhandle, NULL, 0);
|
streamdns_handle_incoming_data(sock, sock->outerhandle, NULL, 0);
|
||||||
|
detach:
|
||||||
|
isc__nmsocket_detach(&sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -847,9 +848,8 @@ isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb,
|
|||||||
if (!closing && isc_dnsstream_assembler_result(sock->streamdns.input) ==
|
if (!closing && isc_dnsstream_assembler_result(sock->streamdns.input) ==
|
||||||
ISC_R_UNSET)
|
ISC_R_UNSET)
|
||||||
{
|
{
|
||||||
isc__netievent_streamdnsread_t event = { .sock = sock };
|
isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL });
|
||||||
isc__nm_async_streamdnsread(sock->worker,
|
streamdns_read_cb(sock);
|
||||||
(isc__netievent_t *)&event);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -863,9 +863,9 @@ isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb,
|
|||||||
* 2. Due to the above, we need to make the operation
|
* 2. Due to the above, we need to make the operation
|
||||||
* asynchronous to keep the socket state consistent.
|
* asynchronous to keep the socket state consistent.
|
||||||
*/
|
*/
|
||||||
isc__netievent_streamdnsread_t *ievent =
|
|
||||||
isc__nm_get_netievent_streamdnsread(sock->worker, sock);
|
isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL });
|
||||||
isc__nm_enqueue_ievent(sock->worker, (isc__netievent_t *)ievent);
|
isc_async_run(sock->worker->loop, streamdns_read_cb, sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user