[dovecot-cvs] dovecot/src/lib ioloop-select.c, 1.17, 1.18 ioloop.c, 1.23, 1.24

cras at dovecot.org cras at dovecot.org
Wed Aug 25 15:09:11 EEST 2004


Update of /home/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv18702

Modified Files:
	ioloop-select.c ioloop.c 
Log Message:
Moved highest_fd calculation to select-specific code. Patch by Andrey Panin.



Index: ioloop-select.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ioloop-select.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- ioloop-select.c	23 Aug 2004 13:47:32 -0000	1.17
+++ ioloop-select.c	25 Aug 2004 12:09:09 -0000	1.18
@@ -17,8 +17,27 @@
 
 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 @@
 		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 @@
 		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) \

Index: ioloop.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ioloop.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- ioloop.c	23 Aug 2004 13:47:32 -0000	1.23
+++ ioloop.c	25 Aug 2004 12:09:09 -0000	1.24
@@ -15,24 +15,6 @@
 
 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 @@
 	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 @@
 		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 @@
         ioloop = p_new(pool, struct ioloop, 1);
 	pool_ref(pool);
 	ioloop->pool = pool;
-	ioloop->highest_fd = -1;
 
 	io_loop_handler_init(ioloop);
 



More information about the dovecot-cvs mailing list