summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2016-02-24 11:29:15 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-02-24 11:32:57 (GMT)
commit9912557fa9b4c8596c6e9f69857e9a616b4f4f33 (patch) (side-by-side diff)
tree348bcb58c3af3c5138abe6e3bdfda5232fc1e54c
parent4049c8b3ba918949106ef8e96ac5e767f4b9406b (diff)
downloadpies-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 (more/less context) (ignore whitespace changes)
-rw-r--r--src/comp.c2
-rw-r--r--src/ctl.c12
-rw-r--r--src/inetd-bi.c2
-rw-r--r--src/prog.h10
-rw-r--r--src/progman.c51
-rw-r--r--src/sysvinit.c18
6 files changed, 46 insertions, 49 deletions
diff --git a/src/comp.c b/src/comp.c
index 7babae7..41b77ce 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -369,7 +369,7 @@ static int
mark_prog (struct prog *prog, void *data)
{
if (prog_is_leftover (prog))
- prog->v.p.stop = 1;
+ prog->stop = 1;
return 0;
}
diff --git a/src/ctl.c b/src/ctl.c
index 21abf59..a7db410 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -1834,15 +1834,15 @@ selector (struct prog *prog, void *data)
static int
prog_active (struct prog *prog)
{
- if (prog->v.p.active)
+ if (prog->active)
{
if (ISCF_TCPMUX (prog->v.p.comp->flags))
{
prog = progman_locate (prog->v.p.comp->tcpmux);
- return prog && prog->v.p.active;
+ return prog && prog->active;
}
}
- return prog->v.p.active;
+ return prog->active;
}
static struct json_value *
@@ -1912,14 +1912,14 @@ fun_stop (struct json_value *result, struct prog *prog)
{
if (IS_COMPONENT (prog))
{
- if (!prog->v.p.active)
+ if (!prog->active)
{
json_object_set_string (result, "status", "ER");
json_object_set_string (result, "error_message", "already stopped");
return 1;
}
- prog->v.p.active = 0;
+ prog->active = 0;
progman_stop_component (&prog);
json_object_set_string (result, "status", "OK");
}
@@ -1972,7 +1972,7 @@ fun_start (struct json_value *result, struct prog *prog)
json_object_set_string (result, "error_message", "already running");
return 1;
}
- prog->v.p.active = 1;
+ prog->active = 1;
return 0;
}
diff --git a/src/inetd-bi.c b/src/inetd-bi.c
index 2032123..61b6f55 100644
--- a/src/inetd-bi.c
+++ b/src/inetd-bi.c
@@ -305,7 +305,7 @@ tcpmux_help (struct component *comp, void *data)
{
int *pfd = data;
- if (ISCF_TCPMUX (comp->flags) && comp->prog && comp->prog->v.p.active)
+ if (ISCF_TCPMUX (comp->flags) && comp->prog && comp->prog->active)
{
fd_report (*pfd, comp->service);
fd_report (*pfd, "\r\n");
diff --git a/src/prog.h b/src/prog.h
index 3358885..be072e1 100644
--- a/src/prog.h
+++ b/src/prog.h
@@ -45,15 +45,14 @@ struct prog
struct prog *next, *prev;
enum prog_type type;
pid_t pid; /* PID */
- int facility;
+ int active :1; /* The prog is active */
+ int wait :1; /* Wait for this prog to terminate */
+ int stop :1; /* Stop this prog */
union
{
struct
{
struct component *comp;
- int active :1; /* The prog is active */
- int wait :1; /* Wait for this prog to terminate */
- int stop :1; /* Stop this prog */
int socket;
struct prog *redir[2]; /* Pointers to redirectors */
time_t timestamp; /* Time of last startup */
@@ -84,8 +83,7 @@ struct prog
};
#define IS_COMPONENT(p) ((p)->type == TYPE_COMPONENT)
-#define IS_ACTIVE_COMPONENT(prog) \
- (IS_COMPONENT(prog) && (prog)->v.p.active)
+#define IS_ACTIVE_COMPONENT(prog) (IS_COMPONENT(prog) && (prog)->active)
struct prog *progman_locate (const char *name);
int progman_foreach (int (*filter) (struct prog *, void *data), void *data);
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;
}
diff --git a/src/sysvinit.c b/src/sysvinit.c
index bbd97f3..0b12b4a 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -243,7 +243,7 @@ enablecomp (struct prog *prog, void *data)
case pies_comp_ondemand:
/* Active flag persists: */
- return prog->v.p.active;
+ return prog->active;
case pies_comp_powerfail:
case pies_comp_powerwait:
@@ -282,18 +282,18 @@ runlevel_setup_prog (struct prog *prog, void *data)
&& is_sysvinit (prog->v.p.comp))
{
int rc = enablecomp (prog, data);
- if (rc < 0 || prog->v.p.active == rc)
+ if (rc < 0 || prog->active == rc)
return 0;
- prog->v.p.active = rc;
+ prog->active = rc;
if (rc)
- prog->v.p.wait = is_comp_wait (prog->v.p.comp);
+ prog->wait = is_comp_wait (prog->v.p.comp);
else if (prog->v.p.status != status_stopped
&& prog->v.p.status != status_finished)
- prog->v.p.stop = 1;
+ prog->stop = 1;
debug (2, ("%s: %s%s", prog_tag (prog),
- prog->v.p.active ?
+ prog->active ?
"enabled" : "disabled",
- prog->v.p.active && prog->v.p.wait ? " (wait)" : ""));
+ prog->active && prog->wait ? " (wait)" : ""));
}
return 0;
}
@@ -316,7 +316,7 @@ demand_prog (struct prog *prog, void *data)
&& comp->runlevels
&& strchr (comp->runlevels, *rl))
{
- prog->v.p.active = 1;
+ prog->active = 1;
debug (1, ("%s: %s", prog_tag (prog), "enabled"));
}
return 0;
@@ -764,7 +764,7 @@ sysvinit_begin (void)
#define IS_RUNNING_DISABLED_PROG(prog) \
(IS_COMPONENT (prog) \
&& prog->v.p.status == status_running \
- && !prog->v.p.active)
+ && !prog->active)
int
inittrans (void)

Return to:

Send suggestions and report system problems to the System administrator.