]> code.citadel.org Git - citadel.git/blobdiff - citadel/event_client.c
EVENT: when handling errors EAGAIN isn't fatal.
[citadel.git] / citadel / event_client.c
index 2f6f0856d6d66dc5ba084677105e99aa2e4788dc..c4016dc1c6e2a3b4c53e3f39d5d4f58604ccd7af 100644 (file)
@@ -584,13 +584,18 @@ IO_send_callback(struct ev_loop *loop, ev_io *watcher, int revents)
                }
        }
        else if (rc < 0) {
-               IO_Timeout_callback(loop, &IO->rw_timeout, revents);
+               if (errno != EAGAIN) {
+                       IO_Timeout_callback(loop, &IO->rw_timeout, revents);
+               }
        }
        /* else : must write more. */
 }
 static void
 set_start_callback(struct ev_loop *loop, AsyncIO *IO, int revents)
 {
+       ev_timer_stop(event_base, &IO->conn_fail);
+       ev_timer_start(event_base, &IO->rw_timeout);
+
        switch(IO->NextState) {
        case eReadMore:
        case eReadMessage:
@@ -722,7 +727,7 @@ IO_connestd_callback(struct ev_loop *loop, ev_io *watcher, int revents)
                          (void*)&so_err,
                          &lon);
 
-        if ((err == 0) && (so_err == 111))
+        if ((err == 0) && (so_err != 0))
         {
                 EV_syslog(LOG_DEBUG, "connect() failed [%d][%s]\n",
                           so_err,
@@ -803,12 +808,14 @@ IO_recv_callback(struct ev_loop *loop, ev_io *watcher, int revents)
                IO_Timeout_callback(loop, &IO->rw_timeout, revents);
                return;
        } else if (nbytes == -1) {
-               // FD is gone. kick it. 
-               StopClientWatchers(IO);
-               EV_syslog(LOG_DEBUG,
-                         "EVENT: Socket Invalid! %s \n",
-                         strerror(errno));
-               ShutDownCLient(IO);
+               if (errno != EAGAIN) {
+                       // FD is gone. kick it. 
+                       StopClientWatchers(IO);
+                       EV_syslog(LOG_DEBUG,
+                                 "EVENT: Socket Invalid! %s \n",
+                                 strerror(errno));
+                       ShutDownCLient(IO);
+               }
                return;
        }
 }
@@ -948,7 +955,6 @@ eNextState EvConnectSock(AsyncIO *IO,
        if (rc >= 0){
                EVM_syslog(LOG_DEBUG, "connect() immediate success.\n");
                set_start_callback(event_base, IO, 0);
-               ev_timer_start(event_base, &IO->rw_timeout);
                return IO->NextState;
        }
        else if (errno == EINPROGRESS) {