diff options
-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 @@ -711,9 +711,9 @@ cb_listen(enum grecs_callback_command cmd, grecs_node_t *node, interface_ref(lp->iface); listener_list_add(&clist, lp); } else if (listener_cmp(p, lp)) { - listener_decommission(p); interface_ref(lp->iface); listener_list_add(&clist, lp); + listener_decommission(p); } else listener_free(lp); } diff --git a/src/jumper.c b/src/jumper.c index 922172a..16d6142 100644 --- a/src/jumper.c +++ b/src/jumper.c @@ -259,7 +259,6 @@ main(int argc, char **argv) command = command_none; } - listener_proc_report(); rdset = fdset; rc = select(maxfd + 1, &rdset, NULL, NULL, progman_timeout(&tv)); diff --git a/src/jumper.h b/src/jumper.h index 5aea623..448e8ef 100644 --- a/src/jumper.h +++ b/src/jumper.h @@ -236,7 +236,7 @@ int listener_cmp(listener_t *a, listener_t *b); listener_t *listener_locate(uint32_t src, uint32_t dst); 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); void listener_start(listener_t *lp, char **kve); int listener_run_action(listener_t *lp, int a); diff --git a/src/listener.c b/src/listener.c index d68897d..69f4b52 100644 --- a/src/listener.c +++ b/src/listener.c @@ -233,6 +233,11 @@ listener_cmp(listener_t *a, listener_t *b) return 1; } + 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)) { debug(5, ("%s/%s: match-source lists differ", a->id, b->id)); return 1; @@ -532,23 +537,13 @@ 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); } void diff --git a/src/progman.c b/src/progman.c index ef5c73d..b9a0f5f 100644 --- a/src/progman.c +++ b/src/progman.c @@ -50,7 +50,6 @@ static struct process *ts_proc_list, *ts_proc_tail; static struct process *proc_avail; static unsigned proc_count; /* Total number of processes in proc_list */ -int proc_stop; /* Number of terminated processes */ static char * @@ -289,7 +288,7 @@ progman_cleanup(void) proc_kill(p->lp); p->lp->progstat = status; p->lp->status = stat_term; - proc_stop++; + listener_proc_report(p->lp); break; case type_redirector: @@ -338,7 +337,6 @@ progman_terminate(void) for (p = proc_list; p; p = p->next) kill(p->pid, SIGKILL); } - listener_proc_report(); sleep(1); } } @@ -349,15 +347,20 @@ progman_decommission(void) struct process *p; time_t start; size_t count = 0; + int info_shown = 0; if (proc_count == 0) return; - 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); count++; } @@ -372,7 +375,6 @@ progman_decommission(void) kill(p->pid, SIGKILL); } progman_cleanup(); - listener_proc_report(); sleep(1); count = 0; for (p = proc_list; p; p = p->next) |