]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
ioloop poll: Added assert to catch double-io_add()s.
authorTimo Sirainen <tss@iki.fi>
Thu, 6 Aug 2009 00:24:56 +0000 (20:24 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 6 Aug 2009 00:24:56 +0000 (20:24 -0400)
--HG--
branch : HEAD

src/lib/ioloop-poll.c

index c7ae258989396f3e2f58f53877c07063aee8bbd4..1d9b4649b88ed7a4e33c892fa81ebc43cfc20834 100644 (file)
@@ -47,7 +47,7 @@ void io_loop_handle_add(struct io_file *io)
        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 *io)
                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)