summaryrefslogtreecommitdiff
path: root/evmap.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-04-28 11:51:56 -0400
committerNick Mathewson <nickm@torproject.org>2010-04-28 12:20:18 -0400
commitcb6707405cc07e34925e9c9f81a0c4d34ef9b135 (patch)
tree8c21dcff659dc619d382c36640f4047529ba0e63 /evmap.c
parenta5208fe4228b0e2c77d43dd2e3991f2fbac9148a (diff)
downloadlibevent-cb6707405cc07e34925e9c9f81a0c4d34ef9b135.tar.gz
Make debug mode catch mixed ET and non-ET events on an fd
Of the backends that support edge-triggered IO, most (all?) do not support attempts to mix edge-triggered and level-triggered IO on the same FD. With debugging mode enabled, we now detect and refuse attempts to add a level-triggered IO event to an fd that already has an edge-triggered IO event, and vice versa.
Diffstat (limited to 'evmap.c')
-rw-r--r--evmap.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/evmap.c b/evmap.c
index b11ec3c9..cb28002a 100644
--- a/evmap.c
+++ b/evmap.c
@@ -264,6 +264,7 @@ evmap_io_add(struct event_base *base, evutil_socket_t fd, struct event *ev)
struct evmap_io *ctx = NULL;
int nread, nwrite, retval = 0;
short res = 0, old = 0;
+ struct event *old_ev;
EVUTIL_ASSERT(fd == ev->ev_fd);
@@ -300,6 +301,13 @@ evmap_io_add(struct event_base *base, evutil_socket_t fd, struct event *ev)
(int)fd);
return -1;
}
+ if (EVENT_DEBUG_MODE_IS_ON() &&
+ (old_ev = TAILQ_FIRST(&ctx->events)) &&
+ (old_ev->ev_events&EV_ET) != (ev->ev_events&EV_ET)) {
+ event_warnx("Tried to mix edge-triggered and non-edge-triggered"
+ " events on fd %d", (int)fd);
+ return -1;
+ }
if (res) {
void *extra = ((char*)ctx) + sizeof(struct evmap_io);