diff -urpNX /usr/share/dontdiff -x Makefile dovecot-1.0-test35.vanilla/src/lib/ioloop.c dovecot-1.0-test35/src/lib/ioloop.c --- dovecot-1.0-test35.vanilla/src/lib/ioloop.c 2004-08-23 17:46:41.000000000 +0400 +++ dovecot-1.0-test35/src/lib/ioloop.c 2004-08-25 10:32:08.000000000 +0400 @@ -15,24 +15,6 @@ struct timezone ioloop_timezone; static struct ioloop *current_ioloop = NULL; -static void update_highest_fd(struct ioloop *ioloop) -{ - struct io *io; - int max_highest_fd; - - max_highest_fd = ioloop->highest_fd-1; - ioloop->highest_fd = -1; - - for (io = ioloop->ios; io != NULL; io = io->next) { - if (!io->destroyed && io->fd > ioloop->highest_fd) { - ioloop->highest_fd = io->fd; - - if (ioloop->highest_fd == max_highest_fd) - break; - } - } -} - struct io *io_add(int fd, enum io_condition condition, io_callback_t *callback, void *context) { @@ -53,9 +35,6 @@ struct io *io_add(int fd, enum io_condit io->callback = callback; io->context = context; - if (io->fd > current_ioloop->highest_fd) - current_ioloop->highest_fd = io->fd; - io_loop_handle_add(current_ioloop, io); /* have to append it, or io_destroy() breaks */ @@ -76,17 +55,11 @@ void io_remove(struct io *io) return; } - i_assert(io->fd <= current_ioloop->highest_fd); - /* notify the real I/O handler */ io_loop_handle_remove(current_ioloop, io); io->destroyed = TRUE; - /* check if we removed the highest fd */ - if (io->fd == current_ioloop->highest_fd) - update_highest_fd(current_ioloop); - io->fd = -1; } @@ -275,7 +248,6 @@ struct ioloop *io_loop_create(pool_t poo ioloop = p_new(pool, struct ioloop, 1); pool_ref(pool); ioloop->pool = pool; - ioloop->highest_fd = -1; io_loop_handler_init(ioloop); diff -urpNX /usr/share/dontdiff -x Makefile dovecot-1.0-test35.vanilla/src/lib/ioloop-select.c dovecot-1.0-test35/src/lib/ioloop-select.c --- dovecot-1.0-test35.vanilla/src/lib/ioloop-select.c 2004-08-23 17:46:41.000000000 +0400 +++ dovecot-1.0-test35/src/lib/ioloop-select.c 2004-08-25 10:55:25.000000000 +0400 @@ -17,8 +17,27 @@ struct ioloop_handler_data { static fd_set tmp_read_fds, tmp_write_fds; +static void update_highest_fd(struct ioloop *ioloop) +{ + struct io *io; + int max_highest_fd; + + max_highest_fd = ioloop->highest_fd-1; + ioloop->highest_fd = -1; + + for (io = ioloop->ios; io != NULL; io = io->next) { + if (!io->destroyed && io->fd > ioloop->highest_fd) { + ioloop->highest_fd = io->fd; + + if (ioloop->highest_fd == max_highest_fd) + break; + } + } +} + void io_loop_handler_init(struct ioloop *ioloop) { + ioloop->highest_fd = -1; ioloop->handler_data = p_new(ioloop->pool, struct ioloop_handler_data, 1); FD_ZERO(&ioloop->handler_data->read_fds); @@ -44,6 +63,9 @@ void io_loop_handle_add(struct ioloop *i FD_SET(fd, &ioloop->handler_data->read_fds); if (condition & IO_WRITE) FD_SET(fd, &ioloop->handler_data->write_fds); + + if (io->fd > ioloop->highest_fd) + ioloop->highest_fd = io->fd; } void io_loop_handle_remove(struct ioloop *ioloop, struct io *io) @@ -57,6 +79,10 @@ void io_loop_handle_remove(struct ioloop FD_CLR(fd, &ioloop->handler_data->read_fds); if (condition & IO_WRITE) FD_CLR(fd, &ioloop->handler_data->write_fds); + + /* check if we removed the highest fd */ + if (io->fd == ioloop->highest_fd) + update_highest_fd(ioloop); } #define io_check_condition(fd, condition) \