diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2020-09-11 22:39:11 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2020-09-15 15:55:55 -0300 |
| commit | 88e635ee6397b93a3263dbe7951f637ae4936e39 (patch) | |
| tree | ac4a679987a82b78eaa743c77fbf919597324b78 /lib/northbound_sysrepo.c | |
| parent | eac139f8f26315076d2c5fd94e7ac2fe322be084 (diff) | |
lib: postpone the sysrepo plugin initialization
From Sysrepo's documentation:
"Note: do not use fork() after creating a connection. Sysrepo
internally stores PID of every created connection and this way a
mismatch of PID and connection is created".
Introduce a new "frr_very_late_init" hook in libfrr that is only
called after the daemon is forked (when the '-d' option is used)
and after the configuration is read. This way we can initialize
the sysrepo plugin correctly even when the daemon is daemonized,
and after the Sysrepo CLI commands are processed (only "debug
northbound client sysrepo" for now).
Fixes #7062
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/northbound_sysrepo.c')
| -rw-r--r-- | lib/northbound_sysrepo.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c index 3dec685927..145164b90d 100644 --- a/lib/northbound_sysrepo.c +++ b/lib/northbound_sysrepo.c @@ -742,7 +742,7 @@ static int frr_sr_finish(void) return 0; } -static int frr_sr_module_late_init(struct thread_master *tm) +static int frr_sr_module_very_late_init(struct thread_master *tm) { master = tm; @@ -753,6 +753,12 @@ static int frr_sr_module_late_init(struct thread_master *tm) } hook_register(frr_fini, frr_sr_finish); + + return 0; +} + +static int frr_sr_module_late_init(struct thread_master *tm) +{ frr_sr_cli_init(); return 0; @@ -761,6 +767,7 @@ static int frr_sr_module_late_init(struct thread_master *tm) static int frr_sr_module_init(void) { hook_register(frr_late_init, frr_sr_module_late_init); + hook_register(frr_very_late_init, frr_sr_module_very_late_init); return 0; } |
