summaryrefslogtreecommitdiff
path: root/evmap.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-01-27 16:35:04 -0500
committerNick Mathewson <nickm@torproject.org>2012-01-27 16:35:04 -0500
commit604569bf3f57bd7bc91799083e8a3c6016be863c (patch)
tree09428ea38eba1051b574037d8e4c995f20696108 /evmap.c
parent7622d2659b2fc2d22ebf87be237ea590aee7191a (diff)
downloadlibevent-604569bf3f57bd7bc91799083e8a3c6016be863c.tar.gz
Remove the eventqueue list and the ev_next pointers.
Those pointers were once used to maintain a complete list of inserted IO and signal events. But such a list is now available by walking over ev_io_map and ev_signal_map! So all they did was require extra pointer operations to maintain, and extra 8-16 bytes of storage in each struct event. To be cowardly and keep the option of going back to having this redundancy, I'm wrapping the removed code in a set of ifdefs. This is a first cut; it needs cleanups and stress-testing!! In particular, it just plain disables a couple of functions that could probably be saved. There seems to be a need for an evmap_{io,signal}_foreach() or something.
Diffstat (limited to 'evmap.c')
-rw-r--r--evmap.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/evmap.c b/evmap.c
index 21965607..67a3f1a4 100644
--- a/evmap.c
+++ b/evmap.c
@@ -547,6 +547,45 @@ evmap_signal_reinit(struct event_base *base)
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.
*/
@@ -798,6 +837,8 @@ evmap_check_integrity(struct event_base *base)
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);
@@ -848,6 +889,7 @@ evmap_check_integrity(struct event_base *base)
}
}
+#endif
EVUTIL_ASSERT(nio == 0);
EVUTIL_ASSERT(nsignals == 0);
/* There is no "EVUTIL_ASSERT(ntimers == 0)": eventqueue is only for