From 44d4466e88db8da2b27bd3d64bf8bfe5347da1be Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Sat, 13 Apr 2024 15:55:52 +0200 Subject: [PATCH] Babel now runs in the worker thread --- proto/babel/babel.c | 12 ++++++------ proto/babel/config.Y | 1 + proto/babel/packets.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/proto/babel/babel.c b/proto/babel/babel.c index e215977d..c49870ae 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -1752,14 +1752,14 @@ babel_iface_timer(timer *t) btime next_event = MIN(ifa->next_hello, ifa->next_regular); if (ifa->want_triggered) next_event = MIN(next_event, ifa->next_triggered); - tm_set(ifa->timer, next_event); + tm_set_in(ifa->timer, next_event, p->p.loop); } static inline void babel_iface_kick_timer(struct babel_iface *ifa) { if (ifa->timer->expires > (current_time() + 100 MS)) - tm_start(ifa->timer, 100 MS); + tm_start_in(ifa->timer, 100 MS, ifa->proto->p.loop); } static void @@ -1773,7 +1773,7 @@ babel_iface_start(struct babel_iface *ifa) ifa->next_regular = current_time() + (random() % ifa->cf->update_interval); ifa->next_triggered = current_time() + MIN(1 S, ifa->cf->update_interval / 2); ifa->want_triggered = 0; /* We send an immediate update (below) */ - tm_start(ifa->timer, 100 MS); + tm_start_in(ifa->timer, 100 MS, p->p.loop); ifa->up = 1; babel_send_hello(ifa, 0); @@ -1938,7 +1938,7 @@ babel_add_iface(struct babel_proto *p, struct iface *new, struct babel_iface_con .hook = babel_iface_locked, .data = ifa, }; - lock->target = &global_event_list; + lock->target = birdloop_event_list(p->p.loop); olock_acquire(lock); } @@ -2416,7 +2416,7 @@ static inline void babel_kick_timer(struct babel_proto *p) { if (p->timer->expires > (current_time() + 100 MS)) - tm_start(p->timer, 100 MS); + tm_start_in(p->timer, 100 MS, p->p.loop); } @@ -2630,7 +2630,7 @@ babel_start(struct proto *P) init_list(&p->interfaces); p->timer = tm_new_init(P->pool, babel_timer, p, 1 S, 0); - tm_start(p->timer, 1 S); + tm_start_in(p->timer, 1 S, p->p.loop); p->update_seqno = 1; p->router_id = proto_get_router_id(&cf->c); diff --git a/proto/babel/config.Y b/proto/babel/config.Y index 6a7c071f..06b8d98c 100644 --- a/proto/babel/config.Y +++ b/proto/babel/config.Y @@ -35,6 +35,7 @@ proto: babel_proto ; babel_proto_start: proto_start BABEL { this_proto = proto_config_new(&proto_babel, $1); + this_proto->loop_order = DOMAIN_ORDER(proto); init_list(&BABEL_CFG->iface_list); BABEL_CFG->hold_time = 1 S_; }; diff --git a/proto/babel/packets.c b/proto/babel/packets.c index 1c784c21..23e3ed50 100644 --- a/proto/babel/packets.c +++ b/proto/babel/packets.c @@ -1533,7 +1533,7 @@ babel_kick_queue(struct babel_iface *ifa) */ if ((ifa->sk->tpos == ifa->sk->tbuf) && !ev_active(ifa->send_event)) - ev_schedule(ifa->send_event); + ev_send_loop(ifa->proto->p.loop, ifa->send_event); } /**