};
typedef enum isc__netievent_type {
- netievent_sockstop, /* for multilayer sockets */
+ netievent_nonempty,
} isc__netievent_type;
typedef union {
isc__nm_streamdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result,
bool async);
-void
-isc__nm_async_sockstop(isc__networker_t *worker, isc__netievent_t *ev0);
-
void
isc__nm_incstats(isc_nmsocket_t *sock, isc__nm_statid_t id);
/*%<
NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb);
-NETIEVENT_SOCKET_TYPE(sockstop);
-
/* Now declared the helper functions */
NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb);
-NETIEVENT_SOCKET_DECL(sockstop);
-
void
isc__nm_udp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result,
bool async);
static void
process_netievent(void *arg) {
isc__netievent_t *ievent = (isc__netievent_t *)arg;
- isc__networker_t *worker = ievent->worker;
switch (ievent->type) {
- NETIEVENT_CASE(sockstop);
default:
UNREACHABLE();
}
isc__networker_unref(worker);
}
-NETIEVENT_SOCKET_DEF(sockstop);
-
void
isc__nm_process_ievent(isc__networker_t *worker, isc__netievent_t *event) {
event->worker = worker;
}
}
+static void
+nmsocket_stop_cb(void *arg) {
+ isc_nmsocket_t *listener = arg;
+
+ (void)atomic_fetch_sub(&listener->rchildren, 1);
+ isc_barrier_wait(&listener->stop_barrier);
+}
+
void
isc__nmsocket_stop(isc_nmsocket_t *listener) {
- isc__netievent_sockstop_t ievent = { .sock = listener };
-
REQUIRE(VALID_NMSOCK(listener));
REQUIRE(listener->tid == isc_tid());
REQUIRE(listener->tid == 0);
for (size_t i = 1; i < listener->nchildren; i++) {
isc__networker_t *worker =
&listener->worker->netmgr->workers[i];
- isc__netievent_sockstop_t *ev =
- isc__nm_get_netievent_sockstop(worker, listener);
- isc__nm_enqueue_ievent(worker, (isc__netievent_t *)ev);
+ isc_async_run(worker->loop, nmsocket_stop_cb, listener);
}
- isc__nm_async_sockstop(listener->worker, (isc__netievent_t *)&ievent);
+ nmsocket_stop_cb(listener);
INSIST(atomic_load(&listener->rchildren) == 0);
if (!atomic_compare_exchange_strong(&listener->listening,
listener->barriers_initialised = true;
}
-void
-isc__nm_async_sockstop(isc__networker_t *worker, isc__netievent_t *ev0) {
- isc__netievent_sockstop_t *ievent = (isc__netievent_sockstop_t *)ev0;
- isc_nmsocket_t *listener = ievent->sock;
- UNUSED(worker);
-
- (void)atomic_fetch_sub(&listener->rchildren, 1);
- isc_barrier_wait(&listener->stop_barrier);
-}
-
static void
isc__nm_connectcb_job(void *arg) {
isc__nm_uvreq_t *uvreq = arg;