]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Re-arrange fpm_read to reduce code duplication
authorDonald Sharp <sharpd@nvidia.com>
Wed, 5 Oct 2022 15:28:43 +0000 (11:28 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 12 Dec 2022 15:44:57 +0000 (10:44 -0500)
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/dplane_fpm_nl.c

index 6c95be29df560d5fef80926b9e96ee8dcb079d47..8bbafdd5c2889e3fecb2c353937495e47731343f 100644 (file)
@@ -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)