Mercurial > dovecot > original-hg > dovecot-2.2
changeset 17720:7985461cf21c
io_add_istream(): Allow the istream to be added even if it doesn't have fd.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 15 Aug 2014 15:19:24 +0300 |
parents | a45147ddd655 |
children | 664afffb22a3 |
files | src/lib/ioloop.c |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/ioloop.c Fri Aug 15 15:02:59 2014 +0300 +++ b/src/lib/ioloop.c Fri Aug 15 15:19:24 2014 +0300 @@ -36,7 +36,6 @@ { struct io_file *io; - i_assert(fd >= 0); i_assert(callback != NULL); i_assert((condition & IO_NOTIFY) == 0); @@ -56,7 +55,12 @@ if (io->io.ioloop->handler_context == NULL) io_loop_initialize_handler(io->io.ioloop); - io_loop_handle_add(io); + if (fd != -1) + io_loop_handle_add(io); + else { + /* we're adding an istream whose only way to get notified + is to call i_stream_set_input_pending() */ + } if (io->io.ioloop->io_files != NULL) { io->io.ioloop->io_files->prev = io; @@ -73,6 +77,7 @@ { struct io_file *io; + i_assert(fd >= 0); io = io_add_file(fd, condition, source_linenum, callback, context); return &io->io; } @@ -139,7 +144,8 @@ } io_file_unlink(io_file); - io_loop_handle_remove(io_file, closed); + if (io_file->fd != -1) + io_loop_handle_remove(io_file, closed); } }