if (base->sig.ev_signal_added) {
/* we cannot call event_del here because the base has
* not been reinitialized yet. */
- event_queue_remove(base, &base->sig.ev_signal,
- EVLIST_INSERTED);
+ event_queue_remove_inserted(base, &base->sig.ev_signal);
if (base->sig.ev_signal.ev_flags & EVLIST_ACTIVE)
- event_queue_remove(base, &base->sig.ev_signal,
- EVLIST_ACTIVE);
+ event_queue_remove_active(base, &base->sig.ev_signal);
+ if (base->sig.ev_signal_pair[0] != -1)
+ EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[0]);
+ if (base->sig.ev_signal_pair[1] != -1)
+ EVUTIL_CLOSESOCKET(base->sig.ev_signal_pair[1]);
base->sig.ev_signal_added = 0;
}
if (base->th_notify_fd[0] != -1) {
return (0);
}
- TAILQ_FOREACH(ev, &ctx->events, ev_io_next) {
+ void
+ evmap_check_integrity(struct event_base *base)
+ {
+ #define EVLIST_X_SIGFOUND 0x1000
+ #define EVLIST_X_IOFOUND 0x2000
+
+ int i;
+ struct event *ev;
+ struct event_io_map *io = &base->io;
+ struct event_signal_map *sigmap = &base->sigmap;
+ int nsignals, ntimers, nio;
+ nsignals = ntimers = nio = 0;
+
+ TAILQ_FOREACH(ev, &base->eventqueue, ev_next) {
+ EVUTIL_ASSERT(ev->ev_flags & EVLIST_INSERTED);
+ EVUTIL_ASSERT(ev->ev_flags & EVLIST_INIT);
+ ev->ev_flags &= ~(EVLIST_X_SIGFOUND|EVLIST_X_IOFOUND);
+ }
+
+
+ for (i = 0; i < io->nentries; ++i) {
+ struct evmap_io *ctx = io->entries[i];
+ if (!ctx)
+ continue;
+
- TAILQ_FOREACH(ev, &ctx->events, ev_signal_next) {
++ LIST_FOREACH(ev, &ctx->events, ev_io_next) {
+ EVUTIL_ASSERT(!(ev->ev_flags & EVLIST_X_IOFOUND));
+ EVUTIL_ASSERT(ev->ev_fd == i);
+ ev->ev_flags |= EVLIST_X_IOFOUND;
+ nio++;
+ }
+ }
+
+ for (i = 0; i < sigmap->nentries; ++i) {
+ struct evmap_signal *ctx = sigmap->entries[i];
+ if (!ctx)
+ continue;
+
++ LIST_FOREACH(ev, &ctx->events, ev_signal_next) {
+ EVUTIL_ASSERT(!(ev->ev_flags & EVLIST_X_SIGFOUND));
+ EVUTIL_ASSERT(ev->ev_fd == i);
+ ev->ev_flags |= EVLIST_X_SIGFOUND;
+ nsignals++;
+ }
+ }
+
+ TAILQ_FOREACH(ev, &base->eventqueue, ev_next) {
+ if (ev->ev_events & (EV_READ|EV_WRITE)) {
+ EVUTIL_ASSERT(ev->ev_flags & EVLIST_X_IOFOUND);
+ --nio;
+ }
+ if (ev->ev_events & EV_SIGNAL) {
+ EVUTIL_ASSERT(ev->ev_flags & EVLIST_X_SIGFOUND);
+ --nsignals;
+ }
+ }
+
+ EVUTIL_ASSERT(nio == 0);
+ EVUTIL_ASSERT(nsignals == 0);
+ /* There is no "EVUTIL_ASSERT(ntimers == 0)": eventqueue is only for
+ * pending signals and io events.
+ */
+ }