Avoid epoll_ctl(..., EPOLL_CTL_DEL, ...) for closed fds.
authorMichael Poole <mdpoole@troilus.org>
Mon, 8 Jan 2007 04:27:45 +0000 (04:27 +0000)
committerMichael Poole <mdpoole@troilus.org>
Mon, 8 Jan 2007 04:27:45 +0000 (04:27 +0000)
src/ioset-impl.h (struct io_engine): Add "os_closed" parameter to
    remove() method.

src/ioset.c (ioset_close): Add this to the call.

src/ioset-epoll.c (ioset_epoll_remove): Use it to avoid removing the fd
    from epoll_fd, since that epoll_ctl() call will always fail.

src/ioset-select.c (ioset_select_remove): Ignore the new parameter.
git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-81

ChangeLog
src/ioset-epoll.c
src/ioset-impl.h
src/ioset-select.c
src/ioset.c

index a06642188bf2a1d81a56bf4825cd84744a51e9f5..787425d430e7f32396abdbb2b39acbf66e1cda14 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,28 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3
 #
 
+2007-01-08 04:27:45 GMT        Michael Poole <mdpoole@troilus.org>     patch-81
+
+    Summary:
+      Avoid epoll_ctl(..., EPOLL_CTL_DEL, ...) for closed fds.
+    Revision:
+      srvx--devo--1.3--patch-81
+
+    src/ioset-impl.h (struct io_engine): Add "os_closed" parameter to
+        remove() method.
+    
+    src/ioset.c (ioset_close): Add this to the call.
+    
+    src/ioset-epoll.c (ioset_epoll_remove): Use it to avoid removing the fd
+        from epoll_fd, since that epoll_ctl() call will always fail.
+    
+    src/ioset-select.c (ioset_select_remove): Ignore the new parameter.
+
+    modified files:
+     ChangeLog src/ioset-epoll.c src/ioset-impl.h
+     src/ioset-select.c src/ioset.c
+
+
 2007-01-08 04:22:20 GMT        Michael Poole <mdpoole@troilus.org>     patch-80
 
     Summary:
index a6b002eb4dec0e0c26e003c86fea5dd6b7b0c7a7..40e30ba3285bc1d5306ae259167f02a025f3d7c2 100644 (file)
@@ -65,10 +65,11 @@ ioset_epoll_add(struct io_fd *fd)
 }
 
 static void
-ioset_epoll_remove(struct io_fd *fd)
+ioset_epoll_remove(struct io_fd *fd, int closed)
 {
     static struct epoll_event evt;
-    (void)epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd->fd, &evt);
+    if (!closed)
+        (void)epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd->fd, &evt);
 }
 
 static void
index a3c12ceebe99d01d84bc1183bf97f201d52a114d..a7bebeea52ed2071de0febc541377057330a4ff8 100644 (file)
@@ -31,7 +31,7 @@ struct io_engine {
     const char *name;
     int (*init)(void);
     void (*add)(struct io_fd *fd);
-    void (*remove)(struct io_fd *fd);
+    void (*remove)(struct io_fd *fd, int os_closed);
     void (*update)(struct io_fd *fd);
     int (*loop)(struct timeval *timeout);
     void (*cleanup)(void);
index 64afa0fd37dc89a7afb3094d2a3539da4a3925d3..8ece1286318a101898a38eb257544880c6291ff2 100644 (file)
@@ -57,10 +57,11 @@ ioset_select_add(struct io_fd *fd)
 }
 
 static void
-ioset_select_remove(struct io_fd *fd)
+ioset_select_remove(struct io_fd *fd, int closed)
 {
     FD_CLR(fd->fd, &read_fds);
     FD_CLR(fd->fd, &write_fds);
+    (void)closed;
 }
 
 static void
index a199275f1d3fa2c87196a53dc006421de5623902..d237a3b24bb931c70a3ee07ba67123ce80f82c8c 100644 (file)
@@ -321,7 +321,7 @@ ioset_close(struct io_fd *fdp, int os_close) {
     free(fdp->recv.buf);
     if (os_close & 1)
         close(fdp->fd);
-    engine->remove(fdp);
+    engine->remove(fdp, os_close & 1);
     free(fdp);
 }