From 7d83e139378ec25a8a69146784af5227fbe25b4f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 5 Oct 2022 11:28:43 -0400 Subject: [PATCH] zebra: Re-arrange fpm_read to reduce code duplication Signed-off-by: Donald Sharp --- zebra/dplane_fpm_nl.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/zebra/dplane_fpm_nl.c b/zebra/dplane_fpm_nl.c index 6c95be29df56..8bbafdd5c288 100644 --- a/zebra/dplane_fpm_nl.c +++ b/zebra/dplane_fpm_nl.c @@ -467,13 +467,6 @@ static void fpm_read(struct thread *t) /* Let's ignore the input at the moment. */ rv = stream_read_try(fnc->ibuf, fnc->socket, STREAM_WRITEABLE(fnc->ibuf)); - /* We've got an interruption. */ - if (rv == -2) { - /* Schedule next read. */ - thread_add_read(fnc->fthread->master, fpm_read, fnc, - fnc->socket, &fnc->t_read); - return; - } if (rv == 0) { atomic_fetch_add_explicit(&fnc->counters.connection_closes, 1, memory_order_relaxed); @@ -492,14 +485,20 @@ static void fpm_read(struct thread *t) FPM_RECONNECT(fnc); return; } + + /* Schedule the next read */ + thread_add_read(fnc->fthread->master, fpm_read, fnc, fnc->socket, + &fnc->t_read); + + /* We've got an interruption. */ + if (rv == -2) + return; + stream_reset(fnc->ibuf); /* Account all bytes read. */ atomic_fetch_add_explicit(&fnc->counters.bytes_read, rv, memory_order_relaxed); - - thread_add_read(fnc->fthread->master, fpm_read, fnc, fnc->socket, - &fnc->t_read); } static void fpm_write(struct thread *t)