From 47b793064c25c8adcab48cacc018be1675f2448a Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 17 Oct 1998 11:05:18 +0000 Subject: Solve chicken-and-egg problems with protocol startup. We now queue all inactive protocols and don't send route/interface updates to them and when they come up, we resend the whole route/interface tables privately. Removed the "scan interface list after protocol start" work-around. --- nest/proto.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'nest/proto.c') diff --git a/nest/proto.c b/nest/proto.c index 478eb77..6db5a0e 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -15,9 +15,12 @@ #include "lib/resource.h" #include "lib/lists.h" #include "nest/confile.h" +#include "nest/route.h" +#include "nest/iface.h" list protocol_list; list proto_list; +list inactive_proto_list; void * proto_new(struct protocol *pr, unsigned size) @@ -30,7 +33,7 @@ proto_new(struct protocol *pr, unsigned size) p->name = pr->name; p->debug = pr->debug; p->pool = rp_new(&root_pool, pr->name); - add_tail(&proto_list, &p->n); + add_tail(&inactive_proto_list, &p->n); return p; } @@ -40,6 +43,7 @@ protos_preconfig(void) struct protocol *p; init_list(&proto_list); + init_list(&inactive_proto_list); debug("Protocol preconfig\n"); WALK_LIST(p, protocol_list) { @@ -61,18 +65,27 @@ protos_postconfig(void) } } +static void +proto_start(struct proto *p) +{ + rem_node(&p->n); + if (p->start) + p->start(p); + if_feed_baby(p); + rt_feed_baby(p); + add_tail(&proto_list, &p->n); +} void protos_start(void) { - struct proto *p; + struct proto *p, *n; debug("Protocol start\n"); - WALK_LIST(p, proto_list) + WALK_LIST_DELSAFE(p, n, inactive_proto_list) { debug("...%s\n", p->name); - if (p->start) - p->start(p); + proto_start(p); } } @@ -89,6 +102,8 @@ protos_dump_all(void) if (p->dump) p->dump(p); } + WALK_LIST(p, inactive_proto_list) + debug(" inactive %s\n", p->name); } void -- cgit v1.2.3