/** Mapping from signal numbers to enabled (added) events. */
struct event_signal_map sigmap;
+#ifdef _EVENT_USE_EVENTLIST
/** All events that have been enabled (added) in this event_base */
struct event_list eventqueue;
+#endif
/** Stored timeval; used to detect when time is running backwards. */
struct timeval event_tv;
gettime(base, &base->event_tv);
min_heap_ctor(&base->timeheap);
+#ifdef _EVENT_USE_EVENTLIST
TAILQ_INIT(&base->eventqueue);
+#endif
base->sig.ev_signal_pair[0] = -1;
base->sig.ev_signal_pair[1] = -1;
base->th_notify_fd[0] = -1;
}
/* Delete all non-internal events. */
- for (ev = TAILQ_FIRST(&base->eventqueue); ev; ) {
- struct event *next = TAILQ_NEXT(ev, ev_next);
- if (!(ev->ev_flags & EVLIST_INTERNAL)) {
- event_del(ev);
- ++n_deleted;
- }
- ev = next;
- }
+ evmap_signal_delete_all(base);
+ evmap_io_delete_all(base);
while ((ev = min_heap_top(&base->timeheap)) != NULL) {
event_del(ev);
++n_deleted;
mm_free(base->activequeues);
+#ifdef _EVENT_USE_EVENTLIST
EVUTIL_ASSERT(TAILQ_EMPTY(&base->eventqueue));
+#endif
evmap_io_clear(&base->io);
evmap_signal_clear(&base->sigmap);
}
DECR_EVENT_COUNT(base, ev);
ev->ev_flags &= ~EVLIST_INSERTED;
+#ifdef _EVENT_USE_EVENTLIST
TAILQ_REMOVE(&base->eventqueue, ev, ev_next);
+#endif
}
static void
event_queue_remove_active(struct event_base *base, struct event *ev)
ev->ev_flags |= EVLIST_INSERTED;
+#ifdef _EVENT_USE_EVENTLIST
TAILQ_INSERT_TAIL(&base->eventqueue, ev, ev_next);
+#endif
}
static void
void
event_base_dump_events(struct event_base *base, FILE *output)
{
+#ifdef _EVENT_USE_EVENTLIST
+ /* re-enable XXXXXX */
struct event *e;
int i;
fprintf(output, "Inserted events:\n");
(e->ev_res&EV_TIMEOUT)?" Timeout active":"");
}
}
+#endif
}
void
int evmap_io_reinit(struct event_base *base);
int evmap_signal_reinit(struct event_base *base);
+int evmap_io_delete_all(struct event_base *base);
+int evmap_signal_delete_all(struct event_base *base);
+
void evmap_check_integrity(struct event_base *base);
#endif /* _EVMAP_H_ */
return res;
}
+int
+evmap_io_delete_all(struct event_base *base)
+{
+ struct event_io_map *io = &base->io;
+
+#ifdef EVMAP_USE_HT
+ struct event_map_entry **mapent;
+ HT_FOREACH(mapent, event_io_map, io) {
+ struct evmap_io *ctx = &(*mapent)->ent.evmap_io;
+#else
+ evutil_socket_t i;
+ for (i = 0; i < io->nentries; ++i) {
+ struct evmap_io *ctx = io->entries[i];
+ if (!ctx)
+ continue;
+#endif
+ while (LIST_FIRST(&ctx->events))
+ event_del(LIST_FIRST(&ctx->events));
+ }
+
+ return 0;
+}
+
+int
+evmap_signal_delete_all(struct event_base *base)
+{
+ struct event_signal_map *sigmap = &base->sigmap;
+ int i;
+
+ for (i = 0; i < sigmap->nentries; ++i) {
+ struct evmap_signal *ctx = sigmap->entries[i];
+ if (!ctx)
+ continue;
+ while (!LIST_EMPTY(&ctx->events))
+ event_del(LIST_FIRST(&ctx->events));
+ }
+ return 0;
+}
+
/** Per-fd structure for use with changelists. It keeps track, for each fd or
* signal using the changelist, of where its entry in the changelist is.
*/
int nsignals, ntimers, nio;
nsignals = ntimers = nio = 0;
+#ifdef _EVENT_USE_EVENTLIST
+ /* XXXXX no-eventlist implementations can use some of this, surely? */
TAILQ_FOREACH(ev, &base->eventqueue, ev_next) {
EVUTIL_ASSERT(ev->ev_flags & EVLIST_INSERTED);
EVUTIL_ASSERT(ev->ev_flags & EVLIST_INIT);
}
}
+#endif
EVUTIL_ASSERT(nio == 0);
EVUTIL_ASSERT(nsignals == 0);
/* There is no "EVUTIL_ASSERT(ntimers == 0)": eventqueue is only for
struct event_base;
struct event {
TAILQ_ENTRY(event) ev_active_next;
+#ifdef _EVENT_USE_EVENTLIST
TAILQ_ENTRY(event) ev_next;
+#endif
/* for managing timeouts */
union {
TAILQ_ENTRY(event) ev_next_with_common_timeout;