]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Proto: published protocol-loop connections
authorMaria Matejka <mq@ucw.cz>
Sun, 2 Apr 2023 17:34:22 +0000 (19:34 +0200)
committerMaria Matejka <mq@ucw.cz>
Tue, 4 Apr 2023 14:44:54 +0000 (16:44 +0200)
nest/proto.c
nest/protocol.h

index 94ca188d13d1b85fd98e345445096c939f172a7b..877c8ab23841ad646c8a64bf2a5b658e54112657 100644 (file)
@@ -58,27 +58,6 @@ static void channel_check_stopped(struct channel *c);
 static inline int proto_is_done(struct proto *p)
 { return (p->proto_state == PS_DOWN) && proto_is_inactive(p); }
 
-static inline event_list *proto_event_list(struct proto *p)
-{ return p->loop == &main_birdloop ? &global_event_list : birdloop_event_list(p->loop); }
-
-static inline event_list *proto_work_list(struct proto *p)
-{ return p->loop == &main_birdloop ? &global_work_list : birdloop_event_list(p->loop); }
-
-static inline void proto_send_event(struct proto *p)
-{ ev_send(proto_event_list(p), p->event); }
-
-#define PROTO_ENTER_FROM_MAIN(p)    ({ \
-    ASSERT_DIE(birdloop_inside(&main_birdloop)); \
-    struct birdloop *_loop = (p)->loop; \
-    if (_loop != &main_birdloop) birdloop_enter(_loop); \
-    _loop; \
-    })
-
-#define PROTO_LEAVE_FROM_MAIN(loop) ({ if (loop != &main_birdloop) birdloop_leave(loop); })
-
-#define PROTO_LOCKED_FROM_MAIN(p)      for (struct birdloop *_proto_loop = PROTO_ENTER_FROM_MAIN(p); _proto_loop; PROTO_LEAVE_FROM_MAIN(_proto_loop), (_proto_loop = NULL))
-
-
 static inline int channel_is_active(struct channel *c)
 { return (c->channel_state != CS_DOWN); }
 
@@ -576,7 +555,7 @@ channel_check_stopped(struct channel *c)
        return;
 
       channel_set_state(c, CS_DOWN);
-      proto_send_event(c->proto);
+      proto_send_event(c->proto, c->proto->event);
 
       break;
     case CS_PAUSE:
@@ -794,7 +773,7 @@ channel_do_down(struct channel *c)
 
   /* Schedule protocol shutddown */
   if (proto_is_done(c->proto))
-    proto_send_event(c->proto);
+    proto_send_event(c->proto, c->proto->event);
 }
 
 void
@@ -2119,7 +2098,7 @@ proto_do_stop(struct proto *p)
   rt_destroy_sources(&p->sources, p->event);
 
   p->do_stop = 1;
-  proto_send_event(p);
+  proto_send_event(p, p->event);
 }
 
 static void
@@ -2129,7 +2108,7 @@ proto_do_down(struct proto *p)
 
   /* Shutdown is finished in the protocol event */
   if (proto_is_done(p))
-    proto_send_event(p);
+    proto_send_event(p, p->event);
 }
 
 
index dfbfff4664cb2e738eb7ae8b6346db4de013b53f..f9f89c06a0b1fe2bc7fd5c544723976e52c50163 100644 (file)
@@ -232,6 +232,15 @@ void channel_graceful_restart_unlock(struct channel *c);
 
 #define DEFAULT_GR_WAIT        240
 
+static inline event_list *proto_event_list(struct proto *p)
+{ return p->loop == &main_birdloop ? &global_event_list : birdloop_event_list(p->loop); }
+
+static inline event_list *proto_work_list(struct proto *p)
+{ return p->loop == &main_birdloop ? &global_work_list : birdloop_event_list(p->loop); }
+
+static inline void proto_send_event(struct proto *p, event *e)
+{ ev_send(proto_event_list(p), e); }
+
 void channel_show_limit(struct limit *l, const char *dsc, int active, int action);
 void channel_show_info(struct channel *c);
 void channel_cmd_debug(struct channel *c, uint mask);
@@ -250,6 +259,17 @@ struct proto *proto_iterate_named(struct symbol *sym, struct protocol *proto, st
 
 #define PROTO_WALK_CMD(sym,pr,p) for(struct proto *p = NULL; p = proto_iterate_named(sym, pr, p); )
 
+#define PROTO_ENTER_FROM_MAIN(p)    ({ \
+    ASSERT_DIE(birdloop_inside(&main_birdloop)); \
+    struct birdloop *_loop = (p)->loop; \
+    if (_loop != &main_birdloop) birdloop_enter(_loop); \
+    _loop; \
+    })
+
+#define PROTO_LEAVE_FROM_MAIN(loop) ({ if (loop != &main_birdloop) birdloop_leave(loop); })
+
+#define PROTO_LOCKED_FROM_MAIN(p)      for (struct birdloop *_proto_loop = PROTO_ENTER_FROM_MAIN(p); _proto_loop; PROTO_LEAVE_FROM_MAIN(_proto_loop), (_proto_loop = NULL))
+
 
 #define CMD_RELOAD     0
 #define CMD_RELOAD_IN  1