Handle EAGAIN, ENOBUFS and EINTR a bit better. Ignore them one layer above
authorclaudio <claudio@openbsd.org>
Mon, 21 Apr 2014 12:26:50 +0000 (12:26 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 21 Apr 2014 12:26:50 +0000 (12:26 +0000)
and do not fail and tear down the world when they happen.

usr.sbin/iscsid/connection.c
usr.sbin/iscsid/pdu.c

index b8555a2..464b6ea 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: connection.c,v 1.16 2014/04/20 20:12:31 claudio Exp $ */
+/*     $OpenBSD: connection.c,v 1.17 2014/04/21 12:26:50 claudio Exp $ */
 
 /*
  * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@@ -131,6 +131,10 @@ conn_dispatch(int fd, short event, void *arg)
                return;
        }
        if ((n = pdu_read(c)) == -1) {
+               if (errno == EAGAIN || errno == ENOBUFS ||
+                   errno == EINTR)     /* try later */
+                       return;
+               log_warn("pdu_read");
                conn_fsm(c, CONN_EV_FAIL);
                return;
        }
index 8167f66..a73c19e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: pdu.c,v 1.8 2014/04/20 18:17:12 claudio Exp $ */
+/*     $OpenBSD: pdu.c,v 1.9 2014/04/21 12:26:50 claudio Exp $ */
 
 /*
  * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@@ -246,15 +246,8 @@ pdu_read(struct connection *c)
                }
        }
 
-       if ((n = readv(c->fd, iov, niov)) == -1) {
-               if (errno == EAGAIN || errno == ENOBUFS ||
-                   errno == EINTR)     /* try later */
-                       return 0;
-               else {
-                       log_warn("pdu_read");
-                       return -1;
-               }
-       }
+       if ((n = readv(c->fd, iov, niov)) == -1)
+               return -1;
        if (n == 0)
                /* XXX what should we do on close with remaining data? */
                return 0;