[IOMultiplexer] do not request events from closed descriptors
[ChatPrototype.git] / src / IOHandler.c
index 4f057e8ef3db36cb4bd65dac770172090eba8ed6..f9e74d0cbf991e2935581c8ccbc84e1f302dbc33 100644 (file)
@@ -111,9 +111,9 @@ static void iohandler_append(struct IODescriptor *descriptor) {
                 if(timeval_is_smaler(timeout, (&iofd->timeout))) {
                     descriptor->prev = iofd->prev;
                     descriptor->next = iofd;
-                    iofd->prev = descriptor;
                     if(iofd->prev)
                         iofd->prev->next = descriptor;
+                    iofd->prev = descriptor;
                     if(set_priority)
                         timer_priority = descriptor;
                     break;
@@ -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);