From f9cc11ec63a921c1bbc5eb25dc0227ef4af699b4 Mon Sep 17 00:00:00 2001 From: claudio Date: Mon, 21 Apr 2014 12:26:50 +0000 Subject: [PATCH] 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. --- usr.sbin/iscsid/connection.c | 6 +++++- usr.sbin/iscsid/pdu.c | 13 +++---------- 2 files changed, 8 insertions(+), 11 deletions(-) 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; -- 2.20.1