Skip to content

Commit

Permalink
zebra: Re-arrange fpm_read to reduce code duplication
Browse files Browse the repository at this point in the history
Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Dec 12, 2022
1 parent 06525c4 commit 7d83e13
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions zebra/dplane_fpm_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit 7d83e13

Please sign in to comment.