mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Proto: published protocol-loop connections
This commit is contained in:
parent
9508cd85ce
commit
a26d307eab
29
nest/proto.c
29
nest/proto.c
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user