dovecot-2.2: io_add_istream(): Allow the istream to be added eve...

dovecot at dovecot.org dovecot at dovecot.org
Fri Aug 15 12:25:02 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/7985461cf21c
changeset: 17720:7985461cf21c
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Aug 15 15:19:24 2014 +0300
description:
io_add_istream(): Allow the istream to be added even if it doesn't have fd.

diffstat:

 src/lib/ioloop.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (43 lines):

diff -r a45147ddd655 -r 7985461cf21c src/lib/ioloop.c
--- 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);
 	}
 }
 


More information about the dovecot-cvs mailing list