diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-01-26 00:49:27 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-01-26 00:49:27 +0200 |
commit | dba0361eb509d3c9a633e05945378a204a4a0f4e (patch) | |
tree | 98c1d161f5ccb34b217d427d444fc835169492bd | |
parent | 1f1d9bb64c4c4e0a0127502f896db8f641a0748a (diff) | |
download | jumper-dba0361eb509d3c9a633e05945378a204a4a0f4e.tar.gz jumper-dba0361eb509d3c9a633e05945378a204a4a0f4e.tar.bz2 |
Fix program reload. Avoid rescanning the process list twice.
* src/config.c (cb_listen): Register new version of the listener
first, and then decommission the existing one. This order is important
to avoid dereferencing interface, if it hasn't changed.
* src/jumper.c (main): Remove call to listener_proc_report
* src/jumper.h (listener_proc_report): Change signature.
* src/listener.c (listener_cmp): Compare command lines.
(listener_proc_report): Rewrite.
* src/progman.c (proc_stop): Remove global.
(progman_cleanup): Call listener_proc_report here.
(progman_decommission): Remove call to listener_proc_report.
Display diagnostics (info and debug) only if some listeners are
going to be decommissioned.
-rw-r--r-- | src/config.c | 2 | ||||
-rw-r--r-- | src/jumper.c | 1 | ||||
-rw-r--r-- | src/jumper.h | 2 | ||||
-rw-r--r-- | src/listener.c | 27 | ||||
-rw-r--r-- | src/progman.c | 16 |
5 files changed, 22 insertions, 26 deletions
diff --git a/src/config.c b/src/config.c index e5cba1b..53d757d 100644 --- a/src/config.c +++ b/src/config.c @@ -713,5 +713,5 @@ cb_listen(enum grecs_callback_command cmd, grecs_node_t *node, } else if (listener_cmp(p, lp)) { - listener_decommission(p); interface_ref(lp->iface); listener_list_add(&clist, lp); + listener_decommission(p); } else diff --git a/src/jumper.c b/src/jumper.c index 922172a..16d6142 100644 --- a/src/jumper.c +++ b/src/jumper.c @@ -261,3 +261,2 @@ main(int argc, char **argv) - listener_proc_report(); rdset = fdset; diff --git a/src/jumper.h b/src/jumper.h index 5aea623..448e8ef 100644 --- a/src/jumper.h +++ b/src/jumper.h @@ -238,3 +238,3 @@ listener_t *listener_find_id(const char *id); void listener_print_status(listener_t *lp); -void listener_proc_report(void); +void listener_proc_report(listener_t *lp); void listener_kill_redirector(listener_t *lp, int what); diff --git a/src/listener.c b/src/listener.c index d68897d..69f4b52 100644 --- a/src/listener.c +++ b/src/listener.c @@ -235,2 +235,7 @@ listener_cmp(listener_t *a, listener_t *b) + if (strcmp(a->prog, b->prog)) { + debug(5, ("%s/%s: commands differ", a->id, b->id)); + return 1; + } + if (ipv4_match_list_cmp(a->match_source, b->match_source)) { @@ -534,19 +539,9 @@ onexit_reaction(listener_t *lp) void -listener_proc_report() +listener_proc_report(listener_t *lp) { - listener_t *lp; - - if (proc_stop == 0) - return; - proc_stop = 0; - - for (lp = llist.head; lp; lp = lp->next) { - if (lp->status == stat_term) { - listener_print_status(lp); - if (lp->decommission) - listener_run_action(lp, event_cleanup); - else - onexit_reaction(lp); - } - } + listener_print_status(lp); + if (lp->decommission) + listener_run_action(lp, event_cleanup); + else + onexit_reaction(lp); } diff --git a/src/progman.c b/src/progman.c index ef5c73d..b9a0f5f 100644 --- a/src/progman.c +++ b/src/progman.c @@ -52,3 +52,2 @@ static struct process *proc_avail; static unsigned proc_count; /* Total number of processes in proc_list */ -int proc_stop; /* Number of terminated processes */ @@ -291,3 +290,3 @@ progman_cleanup(void) p->lp->status = stat_term; - proc_stop++; + listener_proc_report(p->lp); break; @@ -340,3 +339,2 @@ progman_terminate(void) } - listener_proc_report(); sleep(1); @@ -351,2 +349,3 @@ progman_decommission(void) size_t count = 0; + int info_shown = 0; @@ -355,7 +354,11 @@ progman_decommission(void) - diag(LOG_INFO, "terminating decommissioned processes"); - - debug(1, ("sending running decommissioned processes the TERM signal")); for (p = proc_list; p; p = p->next) if (p->type != type_redirector && p->lp->decommission) { + if (!info_shown) { + diag(LOG_INFO, + "terminating decommissioned processes"); + debug(1, + ("sending running decommissioned processes the TERM signal")); + info_shown = 1; + } kill(p->pid, SIGTERM); @@ -374,3 +377,2 @@ progman_decommission(void) progman_cleanup(); - listener_proc_report(); sleep(1); |