summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria Matejka <mq@jmq.cz>2021-12-02 11:41:53 +0000
committerMaria Matejka <mq@ucw.cz>2021-12-07 13:05:20 +0100
commit2117864a87cf9c83d645e5ed1b0863b0e9e95f9a (patch)
tree6354fd966af757ce1fcf72dba2c229be0577ac66
parentc5b6b184135b898a22c2a5ab9690c570c3def603 (diff)
Main IO loop shouldn't skip sockets when ping is received
-rw-r--r--sysdep/unix/io.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index eee7b586..cb6a0754 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -2200,6 +2200,7 @@ io_loop(void)
{
int poll_tout, timeout;
int nfds, events, pout;
+ int reload_requested = 0;
timer *t;
sock *s;
node *n;
@@ -2216,8 +2217,9 @@ io_loop(void)
timers_fire(&main_birdloop.time, 1);
io_close_event();
+restart_poll:
// FIXME
- poll_tout = (events ? 0 : 3000); /* Time in milliseconds */
+ poll_tout = ((reload_requested || events) ? 0 : 3000); /* Time in milliseconds */
if (t = timers_first(&main_birdloop.time))
{
times_update();
@@ -2300,16 +2302,23 @@ io_loop(void)
continue;
die("poll: %m");
}
+
+ if (pout && (pfd[0].revents & POLLIN))
+ {
+ /* IO loop reload requested */
+ pipe_drain(main_birdloop.wakeup_fds[0]);
+ reload_requested = 1;
+ goto restart_poll;
+ }
+
+ if (reload_requested)
+ {
+ reload_requested = 0;
+ atomic_exchange_explicit(&main_birdloop.ping_sent, 0, memory_order_acq_rel);
+ }
+
if (pout)
{
- if (pfd[0].revents & POLLIN)
- {
- /* IO loop reload requested */
- pipe_drain(main_birdloop.wakeup_fds[0]);
- atomic_exchange_explicit(&main_birdloop.ping_sent, 0, memory_order_acq_rel);
- continue;
- }
-
times_update();
/* guaranteed to be non-empty */