[dovecot-cvs] dovecot/src/lib ioloop-kqueue.c,1.4.2.4,1.4.2.5

cras at dovecot.org cras at dovecot.org
Thu Aug 17 20:43:59 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv26100

Modified Files:
      Tag: branch_1_0
	ioloop-kqueue.c 
Log Message:
Fixes



Index: ioloop-kqueue.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ioloop-kqueue.c,v
retrieving revision 1.4.2.4
retrieving revision 1.4.2.5
diff -u -d -r1.4.2.4 -r1.4.2.5
--- ioloop-kqueue.c	16 Aug 2006 21:33:38 -0000	1.4.2.4
+++ ioloop-kqueue.c	17 Aug 2006 17:43:57 -0000	1.4.2.5
@@ -61,34 +61,11 @@
 
 static int io_filter(struct io *io)
 {
-	int filter = 0;
-
+	if ((io->condition & IO_WRITE) != 0)
+		return EVFILT_WRITE;
 	if ((io->condition & (IO_READ | IO_ERROR)) != 0)
-		filter |= EVFILT_READ;
-	if ((io->condition & (IO_WRITE | IO_ERROR)) != 0)
-		filter |= EVFILT_WRITE;
-
-	return filter;
-}
-
-static int io_list_filter(struct io_list *list)
-{
-	int filter = 0, i;
-	struct io *io;
-
-	for (i = 0; i < IOLOOP_IOLIST_IOS_PER_FD; i++) {
-		io = list->ios[i];
-
-		if (io == NULL)
-			continue;
-
-		if ((io->condition & (IO_READ | IO_ERROR)) != 0)
-			filter |= EVFILT_READ;
-		if ((io->condition & (IO_WRITE | IO_ERROR)) != 0)
-			filter |= EVFILT_WRITE;
-	}
-
-	return filter;
+		return EVFILT_READ;
+	return 0;
 }
 
 void io_loop_handle_add(struct ioloop *ioloop, struct io *io)
@@ -101,7 +78,6 @@
 	list = array_idx_modifyable(&ctx->fd_index, io->fd);
 	if (*list == NULL)
 		*list = p_new(ioloop->pool, struct io_list, 1);
-
 	first = ioloop_iolist_add(*list, io);
 
 	EV_SET(&ev, io->fd, io_filter(io), EV_ADD, 0, 0, *list);
@@ -123,14 +99,12 @@
 	struct ioloop_handler_context *ctx = ioloop->handler_context;
 	struct io_list **list;
 	struct kevent ev;
-	int filter;
 	bool last;
 	
 	list = array_idx_modifyable(&ctx->fd_index, io->fd);
 	last = ioloop_iolist_del(*list, io);
 
-	filter = io_filter(io) & ~io_list_filter(*list);
-	EV_SET(&ev, io->fd, filter, EV_DELETE, 0, 0, *list);
+	EV_SET(&ev, io->fd, io_filter(io), EV_DELETE, 0, 0, *list);
 	if (kevent(ctx->kq, &ev, 1, NULL, 0, NULL) < 0)
 		i_error("kevent(EV_DELETE, %d) failed: %m", io->fd);
 
@@ -152,7 +126,7 @@
 	struct io_list *list;
 	unsigned int events_count, t_id;
 	int msecs, ret, i, j;
-	bool call, called;
+	bool call;
 
 	/* get the time left for next timeout task */
 	msecs = io_loop_get_wait_time(ioloop->timeouts, &tv, NULL);
@@ -177,9 +151,9 @@
 		event = array_idx(&ctx->events, i);
 		list = (void *)event->udata;
 
-		called = FALSE;
 		for (j = 0; j < IOLOOP_IOLIST_IOS_PER_FD; j++) {
 			struct io *io = list->ios[j];
+
 			if (io == NULL)
 				continue;
 
@@ -191,12 +165,11 @@
 			} else if ((event->flags & EV_EOF) != 0)
 				call = TRUE;
 			else if ((io->condition & IO_READ) != 0)
-				call = (event->filter & EVFILT_READ) != 0;
+				call = event->filter == EVFILT_READ;
 			else if ((io->condition & IO_WRITE) != 0)
-				call = (event->filter & EVFILT_WRITE) != 0;
+				call = event->filter == EVFILT_WRITE;
 
 			if (call) {
-				called = TRUE;
 				t_id = t_push();
 				io->callback(io->context);
 				if (t_pop() != t_id) {
@@ -206,18 +179,6 @@
 				}
 			}
 		}
-		if (!called) {
-			i_panic("Unrecognized event: kevent "
-				"{.ident = %d,"
-				" .filter = 0x%04x,"
-				" .flags = 0x%04x,"
-				" .fflags = 0x%08x,"
-				" .data = 0x%08llx}, io filter = %x",
-				event->ident,
-				event->filter, event->flags,
-				event->fflags, (unsigned long long)event->data,
-				io_list_filter(list));
-		}
 	}
 }
 



More information about the dovecot-cvs mailing list