diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2017-02-01 12:51:54 +0100 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2017-02-02 00:55:47 +0100 |
commit | 28e8294caa010c246bccbff308cb2118b7d52bdb (patch) | |
tree | 420b6245cc9d0d869b94d8b183d267e9b6241819 /ldpd/lde.c | |
parent | ldpd: fix a bug in the explicit-null command (diff) | |
download | frr-28e8294caa010c246bccbff308cb2118b7d52bdb.tar.xz frr-28e8294caa010c246bccbff308cb2118b7d52bdb.zip |
ldpd: add synchronous IPC channels
By default all ldpd interprocess communication is asynchronous
(non-blocking socketpairs). Under some circumstances, however, we'll
need synchronous IPC as well. Examples:
* the lde child process requesting labels to zebra (through the parent
process);
* apply an access-list on a given IP prefix (ACLs are only available in
the parent process).
This patch only adds the necessary infrastructure to allow the child
processes to make synchronous requests to the parent process. Later
patches will make use of this new infrastructure.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ldpd/lde.c')
-rw-r--r-- | ldpd/lde.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ldpd/lde.c b/ldpd/lde.c index 91b2b1727..a28862881 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -58,7 +58,7 @@ struct ldpd_conf *ldeconf; struct nbr_tree lde_nbrs = RB_INITIALIZER(&lde_nbrs); static struct imsgev *iev_ldpe; -static struct imsgev *iev_main; +static struct imsgev *iev_main, *iev_main_sync; /* Master of threads. */ struct thread_master *master; @@ -133,15 +133,18 @@ lde(const char *user, const char *group) /* setup signal handler */ signal_init(master, array_size(lde_signals), lde_signals); - /* setup pipe and event handler to the parent process */ - if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) + /* setup pipes and event handlers to the parent process */ + if ((iev_main = calloc(1, sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(&iev_main->ibuf, 3); + imsg_init(&iev_main->ibuf, LDPD_FD_ASYNC); iev_main->handler_read = lde_dispatch_parent; iev_main->ev_read = thread_add_read(master, iev_main->handler_read, iev_main, iev_main->ibuf.fd); iev_main->handler_write = ldp_write_handler; - iev_main->ev_write = NULL; + + if ((iev_main_sync = calloc(1, sizeof(struct imsgev))) == NULL) + fatal(NULL); + imsg_init(&iev_main_sync->ibuf, LDPD_FD_SYNC); /* start the LIB garbage collector */ lde_gc_start_timer(); @@ -162,6 +165,8 @@ lde_shutdown(void) close(iev_ldpe->ibuf.fd); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); + msgbuf_clear(&iev_main_sync->ibuf.w); + close(iev_main_sync->ibuf.fd); lde_gc_stop_timer(); lde_nbr_clear(); @@ -171,6 +176,7 @@ lde_shutdown(void) free(iev_ldpe); free(iev_main); + free(iev_main_sync); log_info("label decision engine exiting"); exit(0); |