diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-24 13:29:15 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-24 13:32:57 +0200 |
commit | 9912557fa9b4c8596c6e9f69857e9a616b4f4f33 (patch) | |
tree | 348bcb58c3af3c5138abe6e3bdfda5232fc1e54c /src/progman.c | |
parent | 4049c8b3ba918949106ef8e96ac5e767f4b9406b (diff) | |
download | pies-9912557fa9b4c8596c6e9f69857e9a616b4f4f33.tar.gz pies-9912557fa9b4c8596c6e9f69857e9a616b4f4f33.tar.bz2 |
Changes in prog structure
* src/prog.h (prog): Remove .facility. Use facility from
the component.
(active,wait,stop): Move from union into the main struct.
All uses changed.
Diffstat (limited to 'src/progman.c')
-rw-r--r-- | src/progman.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/progman.c b/src/progman.c index 852a71c..9f5c466 100644 --- a/src/progman.c +++ b/src/progman.c @@ -74,7 +74,7 @@ progman_lookup_tcpmux (const char *service, const char *master) for (prog = proghead; prog; prog = prog->next) if (IS_COMPONENT (prog) && ISCF_TCPMUX (prog->v.p.comp->flags) - && prog->v.p.active + && prog->active && prog->v.p.comp->service && strcasecmp (prog->v.p.comp->service, service) == 0 && prog->v.p.comp->tcpmux @@ -279,7 +279,6 @@ register_prog0 (struct component *comp) newp = grecs_zalloc (sizeof (*newp)); newp->type = TYPE_COMPONENT; newp->pid = 0; - newp->facility = comp->facility; newp->v.p.comp = comp; newp->v.p.socket = -1; @@ -289,9 +288,9 @@ register_prog0 (struct component *comp) newp->v.p.status = status_stopped; if ((comp->flags & CF_DISABLED) || comp->mode == pies_comp_ondemand) - newp->v.p.active = 0; + newp->active = 0; else - newp->v.p.active = 1; + newp->active = 1; if (comp->mode != pies_comp_exec) comp->redir[RETR_OUT].type = redir_null; @@ -325,7 +324,7 @@ progman_waiting_p (void) for (prog = proghead; prog; prog = prog->next) { - if (IS_COMPONENT (prog) && prog->v.p.wait && prog->pid > 0) + if (IS_COMPONENT (prog) && prog->wait && prog->pid > 0) { debug (3, ("%s: waiting for %s (%lu)", __FUNCTION__, prog_tag (prog), @@ -440,7 +439,7 @@ open_redirector (struct prog *master, int stream) fp = fdopen (p[0], "r"); if (fp == NULL) _exit (1); - openlog (prog_tag (master), LOG_PID, master->facility); + openlog (prog_tag (master), LOG_PID, master->v.p.comp->facility); prio = master->v.p.comp->redir[stream].v.prio; while (getline (&buf, &size, fp) > 0) syslog (prio, "%s", buf); @@ -956,7 +955,7 @@ prog_open_socket (struct prog *prog) if (prog->v.p.socket == -1) { prog->v.p.status = status_stopped; - prog->v.p.active = 0; + prog->active = 0; return 1; } if (listen (prog->v.p.socket, 8)) @@ -965,7 +964,7 @@ prog_open_socket (struct prog *prog) close (prog->v.p.socket); prog->v.p.socket = -1; prog->v.p.status = status_stopped; - prog->v.p.active = 0; + prog->active = 0; return 1; } return 0; @@ -1057,12 +1056,12 @@ prog_start (struct prog *prog) { if (!init_process) { - if (prog->v.p.active) + if (prog->active) { logmsg (LOG_NOTICE, "disabling sysvinit component %s", prog_tag (prog)); prog->v.p.status = status_stopped; - prog->v.p.active = 0; + prog->active = 0; } return; } @@ -1523,7 +1522,7 @@ progman_start (void) break; case status_listener: - if (!prog->v.p.active) + if (!prog->active) disable_socket (prog->v.p.socket); else enable_socket (prog->v.p.socket); @@ -1559,9 +1558,9 @@ progman_wake_sleeping (int onalrm) for (prog = proghead; prog; prog = prog->next) { - if (IS_ACTIVE_COMPONENT (prog) && prog->v.p.wait) + if (IS_ACTIVE_COMPONENT (prog) && prog->wait) { - /* The following works on the assumption that prog->v.p.wait is + /* The following works on the assumption that prog->wait is set when enabling the component and gets cleared right after it has finished. */ if (prog->v.p.status != status_running) @@ -1620,7 +1619,7 @@ prog_start_prerequisites (struct prog *prog) struct component *comp; int warned = 0; - if (!prog->v.p.active) + if (!prog->active) return 1; for (comp = component_depmap_first (depmap_col, prog->v.p.comp->arridx, &pos); comp; @@ -1636,9 +1635,9 @@ prog_start_prerequisites (struct prog *prog) warned = 1; } - if (!prog->v.p.active) + if (!prog->active) { - prog->v.p.active = 0; + prog->active = 0; return 1; } @@ -1735,7 +1734,7 @@ static int mark_for_stopping (struct prog *prog, void *data) { if (IS_COMPONENT (prog)) - prog->v.p.stop = 1; + prog->stop = 1; return 0; } @@ -2223,7 +2222,7 @@ react (struct prog *prog, int status, pid_t pid) case action_disable: logmsg (LOG_NOTICE, _("disabling component %s"), prog_tag (prog)); - prog->v.p.active = 0; + prog->active = 0; /* FIXME: if (prog->v.p.comp->mode == pies_comp_inetd) disable_socket (prog->v.p.socket); @@ -2262,7 +2261,7 @@ progman_cleanup (int expect_term) { case TYPE_COMPONENT: print_status (prog_tag (prog), pid, status, expect_term); - prog->v.p.stop = 0; + prog->stop = 0; if (prog->v.p.comp->mode == pies_comp_inetd) { struct prog *listener = prog->v.p.listener; @@ -2302,10 +2301,10 @@ progman_cleanup (int expect_term) pid, ""); prog->v.p.status = status_finished; - if (prog->v.p.wait) + if (prog->wait) { pies_schedule_children (PIES_CHLD_WAKEUP); - prog->v.p.wait = 0; + prog->wait = 0; } } else @@ -2366,7 +2365,7 @@ progman_stop_component (struct prog **progptr) prog_deactivate_listener (prog); /* fall through */ case status_stopped: - prog->v.p.stop = 0; + prog->stop = 0; if (!component_is_active (prog->v.p.comp)) destroy_prog (progptr); break; @@ -2374,8 +2373,8 @@ progman_stop_component (struct prog **progptr) case status_sleeping: if (!component_is_active (prog->v.p.comp)) destroy_prog (progptr); - else if (prog->v.p.stop) - prog->v.p.stop = 0; + else if (prog->stop) + prog->stop = 0; else { logmsg (LOG_INFO, _("waking up component %s"), prog_tag (prog)); @@ -2387,7 +2386,7 @@ progman_stop_component (struct prog **progptr) break; case status_finished: - prog->v.p.stop = 0; + prog->stop = 0; if (!component_is_active (prog->v.p.comp)) destroy_prog (progptr); else @@ -2439,7 +2438,7 @@ static struct prog * prog_to_stop (struct prog *prog) { for (; prog; prog = prog->next) - if (IS_COMPONENT (prog) && prog->v.p.stop) + if (IS_COMPONENT (prog) && prog->stop) break; return prog; } |