dovecot-2.0: ioloop poll: Added assert to catch double-io_add()s.

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 6 03:30:52 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/111812403bea
changeset: 9731:111812403bea
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 05 20:24:56 2009 -0400
description:
ioloop poll: Added assert to catch double-io_add()s.

diffstat:

1 file changed, 4 insertions(+), 2 deletions(-)
src/lib/ioloop-poll.c |    6 ++++--

diffs (28 lines):

diff -r 73daab8251eb -r 111812403bea src/lib/ioloop-poll.c
--- a/src/lib/ioloop-poll.c	Wed Aug 05 20:23:46 2009 -0400
+++ b/src/lib/ioloop-poll.c	Wed Aug 05 20:24:56 2009 -0400
@@ -47,7 +47,7 @@ void io_loop_handle_add(struct io_file *
 	struct ioloop_handler_context *ctx = io->io.ioloop->handler_context;
 	enum io_condition condition = io->io.condition;
 	unsigned int old_count;
-	int index, fd = io->fd;
+	int index, old_events, fd = io->fd;
 
 	if ((unsigned int)fd >= ctx->idx_count) {
                 /* grow the fd -> index array */
@@ -86,12 +86,14 @@ void io_loop_handle_add(struct io_file *
 		ctx->fds[index].revents = 0;
 	}
 
-        if (condition & IO_READ)
+	old_events = ctx->fds[index].events;
+	if (condition & IO_READ)
 		ctx->fds[index].events |= IO_POLL_INPUT;
         if (condition & IO_WRITE)
 		ctx->fds[index].events |= IO_POLL_OUTPUT;
 	if (condition & IO_ERROR)
 		ctx->fds[index].events |= IO_POLL_ERROR;
+	i_assert(ctx->fds[index].events != old_events);
 }
 
 void io_loop_handle_remove(struct io_file *io, bool closed ATTR_UNUSED)


More information about the dovecot-cvs mailing list