Hi

epoll_del must be called to avoid false events, for more info see the patch.

Without this patch, the CGI plugin was really unstable - you would have file 
descriptors after successful open() be invalid etc.

- Lauri
>From 8d84ba337814329e35b26242f4b1d93e7f57b481 Mon Sep 17 00:00:00 2001
From: Lauri Kasanen <[email protected]>
Date: Tue, 12 Jun 2012 23:41:14 +0300
Subject: [PATCH] sched: We must call epoll_del here to work around kernel 
behavior

If the fd is not removed from the epoll set, it keeps getting notified and then 
monkey tries
to close it - and since it now refers to some other file, errors ensue.

This sounds exactly like http://osdir.com/ml/linux-kernel/2009-02/msg10362.html

Signed-off-by: Lauri Kasanen <[email protected]>
---
 src/mk_scheduler.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mk_scheduler.c b/src/mk_scheduler.c
index 2500308..2c4c69d 100644
--- a/src/mk_scheduler.c
+++ b/src/mk_scheduler.c
@@ -338,10 +338,12 @@ int mk_sched_remove_client(struct sched_list_node *sched, 
int remote_fd)
     struct sched_connection *sc;
 
     /*
-     * Close socket and change status: we do not invoke mk_epoll_del()
+     * Close socket and change status: we must invoke mk_epoll_del()
      * because when the socket is closed is cleaned from the queue by
-     * the Kernel.
+     * the Kernel at its leisure, and we may get false events if we rely
+     * on that.
      */
+    mk_epoll_del(sched->epoll_fd, remote_fd);
     close(remote_fd);
 
     sc = mk_sched_get_connection(sched, remote_fd);
-- 
1.7.2.1

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to