summaryrefslogtreecommitdiff
path: root/sysdep/unix/io-loop.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-05-05 16:08:50 +0200
committerMaria Matejka <mq@ucw.cz>2023-05-07 16:58:56 +0200
commit62432affd97b94f257471bd562fc6c680d5a79c3 (patch)
tree8f60c9604f3fbf58e0466b844fc6422372b64d80 /sysdep/unix/io-loop.c
parente0c09e6bee8e9bd8686d8165d819a488dc3e09f8 (diff)
Fixed loop movement to not collide on LTT_MOVE
Diffstat (limited to 'sysdep/unix/io-loop.c')
-rw-r--r--sysdep/unix/io-loop.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c
index 594709d4..a923267c 100644
--- a/sysdep/unix/io-loop.c
+++ b/sysdep/unix/io-loop.c
@@ -355,7 +355,7 @@ birdloop_try_ping(struct birdloop *loop, u32 ltt)
return 1;
}
- /* Do the real ping */
+ /* Do the real ping of Meta or Main */
LOOP_TRACE(loop, "sending pipe ping");
wakeup_do_kick(loop->thread);
return 0;
@@ -617,6 +617,7 @@ birdloop_set_thread(struct birdloop *loop, struct bird_thread *thr, struct birdl
u32 ltt = atomic_fetch_or_explicit(&loop->thread_transition, LTT_MOVE, memory_order_acq_rel);
ASSERT_DIE((ltt & LTT_MOVE) == 0);
+ /* Wait until all previously started pings end */
while (ltt & LTT_PING)
{
birdloop_yield();
@@ -625,9 +626,22 @@ birdloop_set_thread(struct birdloop *loop, struct bird_thread *thr, struct birdl
}
/* Now we are free of running pings */
+ if (!thr)
+ {
+ /* Unschedule from Meta */
+ ev_postpone(&loop->event);
+ tm_stop(&loop->timer);
+
+ /* Request local socket reload */
+ this_thread->sock_changed = 1;
+ }
+
/* Update the thread value */
loop->thread = thr;
+ /* Allow pings */
+ atomic_fetch_and_explicit(&loop->thread_transition, ~LTT_MOVE, memory_order_acq_rel);
+
/* Put into appropriate lists */
if (thr)
{
@@ -637,21 +651,11 @@ birdloop_set_thread(struct birdloop *loop, struct bird_thread *thr, struct birdl
}
else
{
- /* Unschedule from Meta */
- ev_postpone(&loop->event);
- tm_stop(&loop->timer);
-
- /* Request local socket reload */
- this_thread->sock_changed = 1;
-
/* Put into pickup list */
LOCK_DOMAIN(resource, group->domain);
add_tail(&group->loops, &loop->n);
UNLOCK_DOMAIN(resource, group->domain);
}
-
- /* Allow pings */
- atomic_fetch_and_explicit(&loop->thread_transition, ~LTT_MOVE, memory_order_acq_rel);
}
static void
@@ -878,6 +882,7 @@ poll_retry:;
wakeup_drain(thr);
}
+ /* Unset ping information for Meta */
atomic_fetch_and_explicit(&thr->meta->thread_transition, ~LTT_PING, memory_order_acq_rel);
/* Schedule loops with active sockets */