EVENT-Client: don't call the timeout function directly
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 16 Jun 2012 08:49:08 +0000 (10:49 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sat, 16 Jun 2012 08:49:08 +0000 (10:49 +0200)
  - if we call the timeout function directly we might find upper stackframes which rely on the event-context still being valid. Thus we rather set a timeout of 0.0 which then calls the timeout function and kills the context.

citadel/event_client.c

index 774d3e86cecf506087eb2de1b87c5a7c7b17880c..bd0b8a105be45f9cda7a142a32860a8331b36052 100644 (file)
@@ -585,10 +585,14 @@ IO_send_callback(struct ev_loop *loop, ev_io *watcher, int revents)
        }
        else if (rc < 0) {
                if (errno != EAGAIN) {
+                       StopClientWatchers(IO);
                        EV_syslog(LOG_DEBUG,
                                  "EVENT: Socket Invalid! [%d] [%s] [%d]\n",
                                  errno, strerror(errno), IO->SendBuf.fd);
-                       IO_Timeout_callback(loop, &IO->rw_timeout, revents);
+                       StrBufPrintf(IO->ErrMsg,
+                                    "Socket Invalid! [%s]",
+                                    strerror(errno));
+                       SetNextTimeout(IO, 0.0);
                }
        }
        /* else : must write more. */
@@ -808,7 +812,7 @@ IO_recv_callback(struct ev_loop *loop, ev_io *watcher, int revents)
        if (nbytes > 0) {
                HandleInbound(IO);
        } else if (nbytes == 0) {
-               IO_Timeout_callback(loop, &IO->rw_timeout, revents);
+               SetNextTimeout(IO, 0.0);
                return;
        } else if (nbytes == -1) {
                if (errno != EAGAIN) {
@@ -817,7 +821,10 @@ IO_recv_callback(struct ev_loop *loop, ev_io *watcher, int revents)
                        EV_syslog(LOG_DEBUG,
                                  "EVENT: Socket Invalid! [%d] [%s] [%d]\n",
                                  errno, strerror(errno), IO->SendBuf.fd);
-                       ShutDownCLient(IO);
+                       StrBufPrintf(IO->ErrMsg,
+                                    "Socket Invalid! [%s]",
+                                    strerror(errno));
+                       SetNextTimeout(IO, 0.0);
                }
                return;
        }