Mercurial > dovecot > core-2.2
changeset 2480:ac93896adcc3 HEAD
Internal I/O loop API change in preparation for epoll support. Patch by
Andrey Panin.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 23 Aug 2004 16:47:32 +0300 |
parents | a8f363cef34e |
children | 2ad55f027439 |
files | src/lib/ioloop-internal.h src/lib/ioloop-poll.c src/lib/ioloop-select.c src/lib/ioloop.c |
diffstat | 4 files changed, 18 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/ioloop-internal.h Mon Aug 23 13:05:47 2004 +0300 +++ b/src/lib/ioloop-internal.h Mon Aug 23 16:47:32 2004 +0300 @@ -53,10 +53,8 @@ void timeout_destroy(struct ioloop *ioloop, struct timeout **timeout_p); /* I/O handler calls */ -void io_loop_handle_add(struct ioloop *ioloop, int fd, - enum io_condition condition); -void io_loop_handle_remove(struct ioloop *ioloop, int fd, - enum io_condition condition); +void io_loop_handle_add(struct ioloop *ioloop, struct io *io); +void io_loop_handle_remove(struct ioloop *ioloop, struct io *io); void io_loop_handler_init(struct ioloop *ioloop); void io_loop_handler_deinit(struct ioloop *ioloop);
--- a/src/lib/ioloop-poll.c Mon Aug 23 13:05:47 2004 +0300 +++ b/src/lib/ioloop-poll.c Mon Aug 23 16:47:32 2004 +0300 @@ -45,12 +45,12 @@ #define IO_POLL_INPUT (POLLIN|POLLPRI|POLLERR|POLLHUP|POLLNVAL) #define IO_POLL_OUTPUT (POLLOUT|POLLERR|POLLHUP|POLLNVAL) -void io_loop_handle_add(struct ioloop *ioloop, int fd, - enum io_condition condition) +void io_loop_handle_add(struct ioloop *ioloop, struct io *io) { struct ioloop_handler_data *data = ioloop->handler_data; + enum io_condition condition = io->condition; unsigned int old_size; - int index; + int index, fd = io->fd; if ((unsigned int) fd >= data->idx_size) { /* grow the fd -> index array */ @@ -97,11 +97,11 @@ data->fds[index].events |= IO_POLL_OUTPUT; } -void io_loop_handle_remove(struct ioloop *ioloop, int fd, - enum io_condition condition) +void io_loop_handle_remove(struct ioloop *ioloop, struct io *io) { struct ioloop_handler_data *data = ioloop->handler_data; - int index; + enum io_condition condition = io->condition; + int index, fd = io->fd; index = data->fd_index[fd]; i_assert(index >= 0 && (unsigned int) index < data->fds_size);
--- a/src/lib/ioloop-select.c Mon Aug 23 13:05:47 2004 +0300 +++ b/src/lib/ioloop-select.c Mon Aug 23 16:47:32 2004 +0300 @@ -30,9 +30,11 @@ p_free(ioloop->pool, ioloop->handler_data); } -void io_loop_handle_add(struct ioloop *ioloop, int fd, - enum io_condition condition) +void io_loop_handle_add(struct ioloop *ioloop, struct io *io) { + enum io_condition condition = io->condition; + int fd = io->fd; + i_assert(fd >= 0); if (fd >= FD_SETSIZE) @@ -44,9 +46,11 @@ FD_SET(fd, &ioloop->handler_data->write_fds); } -void io_loop_handle_remove(struct ioloop *ioloop, int fd, - enum io_condition condition) +void io_loop_handle_remove(struct ioloop *ioloop, struct io *io) { + enum io_condition condition = io->condition; + int fd = io->fd; + i_assert(fd >= 0 && fd < FD_SETSIZE); if (condition & IO_READ)
--- a/src/lib/ioloop.c Mon Aug 23 13:05:47 2004 +0300 +++ b/src/lib/ioloop.c Mon Aug 23 16:47:32 2004 +0300 @@ -56,7 +56,7 @@ if (io->fd > current_ioloop->highest_fd) current_ioloop->highest_fd = io->fd; - io_loop_handle_add(current_ioloop, io->fd, io->condition); + io_loop_handle_add(current_ioloop, io); /* have to append it, or io_destroy() breaks */ io_p = ¤t_ioloop->ios; @@ -79,7 +79,7 @@ i_assert(io->fd <= current_ioloop->highest_fd); /* notify the real I/O handler */ - io_loop_handle_remove(current_ioloop, io->fd, io->condition); + io_loop_handle_remove(current_ioloop, io); io->destroyed = TRUE;