From: claudio Date: Mon, 21 Apr 2014 12:26:50 +0000 (+0000) Subject: Handle EAGAIN, ENOBUFS and EINTR a bit better. Ignore them one layer above X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f9cc11ec63a921c1bbc5eb25dc0227ef4af699b4;p=openbsd Handle EAGAIN, ENOBUFS and EINTR a bit better. Ignore them one layer above and do not fail and tear down the world when they happen. --- diff --git a/usr.sbin/iscsid/connection.c b/usr.sbin/iscsid/connection.c index b8555a23a3c..464b6ea0df0 100644 --- a/usr.sbin/iscsid/connection.c +++ b/usr.sbin/iscsid/connection.c @@ -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 @@ -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; } diff --git a/usr.sbin/iscsid/pdu.c b/usr.sbin/iscsid/pdu.c index 8167f662821..a73c19e2ccb 100644 --- a/usr.sbin/iscsid/pdu.c +++ b/usr.sbin/iscsid/pdu.c @@ -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 @@ -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;