[IOMultiplexer] do not request events from closed descriptors
authorpk910 <philipp@zoelle1.de>
Wed, 22 Aug 2012 02:16:44 +0000 (04:16 +0200)
committerpk910 <philipp@zoelle1.de>
Wed, 22 Aug 2012 02:16:44 +0000 (04:16 +0200)
src/IOEngine_epoll.c
src/IOEngine_kevent.c
src/IOEngine_select.c
src/IOHandler.c

index 19c62272518c29804a26a41221577afba0b2d0eb..e36394960f3af206bf4fa594fc10732e2de324f1 100644 (file)
@@ -55,6 +55,10 @@ static void engine_epoll_remove(struct IODescriptor *iofd) {
 
 static void engine_epoll_update(struct IODescriptor *iofd) {
     if(iofd->type == IOTYPE_TIMER) return;
+    if(iofd->state == IO_CLOSED) {
+        engine_epoll_remove(iofd);
+        return;
+    }
     struct epoll_event evt;
     int res;
 
index 1ebb801886d1c1a243fed0a3c9b5d3225185b4e3..21c81efcf421bb5fe2bace8b519b055813ba8964 100644 (file)
@@ -59,6 +59,10 @@ static void engine_kevent_remove(struct IODescriptor *iofd) {
 
 static void engine_kevent_update(struct IODescriptor *iofd) {
     if(iofd->type == IOTYPE_TIMER) return;
+    if(iofd->state == IO_CLOSED) {
+        engine_epoll_remove(iofd);
+        return;
+    }
     struct kevent changes[2];
     int nchanges = 0;
     int res;
index 8c25ba6d1036309dcf2f7e1901dfccf18e95c805..2d85d7cc10f0f3b7e7f6bdf597573a3a47e39ea1 100644 (file)
@@ -99,6 +99,8 @@ static void engine_select_loop(struct timeval *timeout) {
             #endif
         }
         else if(iofd->type == IOTYPE_SERVER || iofd->type == IOTYPE_CLIENT) {
+            if(iofd->state == IO_CLOSED) 
+                continue;
             if(iofd->fd > fds_size)
                 fds_size = iofd->fd;
             FD_SET(iofd->fd, &read_fds);
index e4fa1dd6dd30e16c9df9e57c64926e9f7826e3e8..f9e74d0cbf991e2935581c8ccbc84e1f302dbc33 100644 (file)
@@ -553,6 +553,7 @@ void iohandler_events(struct IODescriptor *iofd, int readable, int writeable) {
             if(!readable && !writeable) {
                 callback_event.type = IOEVENT_SSLFAILED;
                 iofd->state = IO_CLOSED;
+                engine->update(iofd);
             } else {
                 iohandler_log(IOLOG_DEBUG, "triggering iohandler_ssl_client_handshake for %s (fd: %d)", iohandler_iotype_name(iofd->type), iofd->fd);
                 iohandler_ssl_client_handshake(iofd);