diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2018-11-30 17:56:04 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2018-12-06 23:05:42 +0100 |
commit | 75f8b0e41b500b02675222515f3173c4effebdfe (patch) | |
tree | f4ecd44103cddaf92ab95c72ef87ebaab75d0fd6 /watchfrr | |
parent | watchfrr: don't wait around pointlessly at startup (diff) | |
download | frr-75f8b0e41b500b02675222515f3173c4effebdfe.tar.xz frr-75f8b0e41b500b02675222515f3173c4effebdfe.zip |
watchfrr: immediately try connecting after start
When we make a call to (re)start some daemon(s), we can immediately try
connecting to its VTY socket after the script completes. If the daemon
started correctly, this will always succeed since the start script only
returns after daemon startup is complete.
Among other things, this reduces the delay to "startup complete"
notification at initial watchfrr start.
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'watchfrr')
-rw-r--r-- | watchfrr/watchfrr.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c index 95fa6c4ae..35a633b15 100644 --- a/watchfrr/watchfrr.c +++ b/watchfrr/watchfrr.c @@ -179,6 +179,7 @@ static int try_connect(struct daemon *dmn); static int wakeup_send_echo(struct thread *t_wakeup); static void try_restart(struct daemon *dmn); static void phase_check(void); +static void restart_done(struct daemon *dmn); static const char *progname; static void printhelp(FILE *target) @@ -335,6 +336,7 @@ static void sigchild(void) const char *name; const char *what; struct restart_info *restart; + struct daemon *dmn; switch (child = waitpid(-1, &status, WNOHANG)) { case -1: @@ -380,9 +382,18 @@ static void sigchild(void) zlog_warn( "%s %s process %d exited with non-zero status %d", what, name, (int)child, WEXITSTATUS(status)); - else + else { zlog_debug("%s %s process %d exited normally", what, name, (int)child); + + if (restart && restart != &gs.restart) { + dmn = container_of(restart, struct daemon, + restart); + restart_done(dmn); + } else if (restart) + for (dmn = gs.daemons; dmn; dmn = dmn->next) + restart_done(dmn); + } } else flog_err_sys( EC_LIB_SYSTEM_CALL, @@ -505,6 +516,18 @@ static int wakeup_init(struct thread *t_wakeup) return 0; } +static void restart_done(struct daemon *dmn) +{ + if (dmn->state != DAEMON_DOWN) { + zlog_warn("wtf?"); + return; + } + if (dmn->t_wakeup) + THREAD_OFF(dmn->t_wakeup); + if (try_connect(dmn) < 0) + SET_WAKEUP_DOWN(dmn); +} + static void daemon_down(struct daemon *dmn, const char *why) { if (IS_UP(dmn) || (dmn->state == DAEMON_INIT)) |