summaryrefslogtreecommitdiff
path: root/nest/protocol.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-04-02 19:34:22 +0200
committerMaria Matejka <mq@ucw.cz>2023-04-04 16:44:54 +0200
commita26d307eabc9d670c8a39ade3b540cabde5851a3 (patch)
tree234fc5c814f3a3deb296d6777d7fd845236062dd /nest/protocol.h
parent9508cd85ce21a476ba47417999d2157594c73c85 (diff)
Proto: published protocol-loop connections
Diffstat (limited to 'nest/protocol.h')
-rw-r--r--nest/protocol.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/nest/protocol.h b/nest/protocol.h
index dfbfff46..f9f89c06 100644
--- a/nest/protocol.h
+++ b/nest/protocol.h
@@ -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