From: Donald Sharp Date: Wed, 13 Jun 2018 13:19:37 +0000 (-0400) Subject: zebra: Cleanup code to test for failure once X-Git-Tag: frr-6.1-dev~327^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=refs%2Fpull%2F2428%2Fhead;p=mirror%2Ffrr.git zebra: Cleanup code to test for failure once Cleanup the zebra code to test for failure for reading from stream once instead of once to see if we should debug and once for the actual failure. Signed-off-by: Donald Sharp --- diff --git a/zebra/zserv.c b/zebra/zserv.c index a099cfc057..14e0db40bf 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -318,11 +318,12 @@ static int zserv_read(struct thread *thread) if (already < ZEBRA_HEADER_SIZE) { nb = stream_read_try(client->ibuf_work, sock, ZEBRA_HEADER_SIZE - already); - if ((nb == 0 || nb == -1) && IS_ZEBRA_DEBUG_EVENT) - zlog_debug("connection closed socket [%d]", - sock); - if ((nb == 0 || nb == -1)) + if ((nb == 0 || nb == -1)) { + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug("connection closed socket [%d]", + sock); goto zread_fail; + } if (nb != (ssize_t)(ZEBRA_HEADER_SIZE - already)) { /* Try again later. */ break; @@ -375,12 +376,13 @@ static int zserv_read(struct thread *thread) if (already < hdr.length) { nb = stream_read_try(client->ibuf_work, sock, hdr.length - already); - if ((nb == 0 || nb == -1) && IS_ZEBRA_DEBUG_EVENT) - zlog_debug( - "connection closed [%d] when reading zebra data", - sock); - if ((nb == 0 || nb == -1)) + if ((nb == 0 || nb == -1)) { + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug( + "connection closed [%d] when reading zebra data", + sock); goto zread_fail; + } if (nb != (ssize_t)(hdr.length - already)) { /* Try again later. */ break;