From: Maria Matejka Date: Sat, 8 Jun 2024 18:06:52 +0000 (+0200) Subject: Thread IO: a little bit faster RX repeat X-Git-Tag: v3.0.0~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=661193cf98438329b9bb5666eb1882533a36d6ec;p=thirdparty%2Fbird.git Thread IO: a little bit faster RX repeat --- diff --git a/lib/io-loop.h b/lib/io-loop.h index 446cd1727..154b0774e 100644 --- a/lib/io-loop.h +++ b/lib/io-loop.h @@ -21,6 +21,7 @@ extern _Thread_local struct birdloop *this_birdloop; /* Check that the task has enough time to do a bit more */ _Bool task_still_in_limit(void); +_Bool task_before_halftime(void); #define MAYBE_DEFER_TASK(target, event, fmt, args...) do { \ if (!task_still_in_limit()) { \ diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c index 01cf74006..ddf190b0f 100644 --- a/sysdep/unix/io-loop.c +++ b/sysdep/unix/io-loop.c @@ -543,9 +543,14 @@ sockets_fire(struct birdloop *loop) if (rev & POLLIN) /* Read just one packet and request repeat. */ - if ((s == loop->sock_active) && s->rx_hook) - if (sk_read(s, rev)) + while ((s == loop->sock_active) && s->rx_hook) + if (!task_before_halftime()) + { repeat++; + break; + } + else if (!sk_read(s, rev)) + break; if (s != loop->sock_active) continue; @@ -1356,6 +1361,11 @@ _Bool task_still_in_limit(void) return ns_now() < account_last + this_thread->max_loop_time_ns; } +_Bool task_before_halftime(void) +{ + return ns_now() < account_last + this_thread->max_loop_time_ns / 2; +} + /* * Birdloop