aboutsummaryrefslogtreecommitdiff
path: root/src/progman.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/progman.c')
-rw-r--r--src/progman.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/src/progman.c b/src/progman.c
index c864966..456b5ff 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -40,7 +40,6 @@ struct prog
enum prog_type type;
pid_t pid; /* PID */
char *tag; /* Entry tag (for diagnostics purposes) */
- int idx; /* Numeric identifier */
char **prereq;
int facility;
union
@@ -48,11 +47,11 @@ struct prog
struct
{
struct component *comp;
- int argc; /* Number of elements in comp->argv */
+ unsigned idx; /* Numeric identifier */
int socket;
struct prog *redir[2]; /* Pointers to redirectors */
- time_t timestamp; /* Time of last startup */
- size_t count; /* Number of failed starts since timestamp */
+ time_t timestamp; /* Time of last startup */
+ size_t count; /* Number of failed starts since timestamp */
enum prog_status status; /* Current component status */
} p;
@@ -70,7 +69,7 @@ struct prog
#define IS_COMPONENT(p) ((p)->type == TYPE_COMPONENT)
-static int numprog;
+static unsigned numcomp;
static struct prog *proghead, *progtail;
static pies_depmap_t depmap;
static int recompute_alarm;
@@ -122,7 +121,7 @@ prog_lookup_by_idx (unsigned idx)
{
struct prog *prog;
for (prog = proghead; prog; prog = prog->next)
- if (prog->idx == idx)
+ if (IS_COMPONENT (prog) && prog->v.p.idx == idx)
break;
return prog;
}
@@ -225,7 +224,6 @@ register_redir (int type, struct prog *master)
pstr += strlen (pp->tag) + 1;
free (tag);
pp->v.r.master = master;
- pp->idx = -1; /* Retranslators are not indexed */
pp->prereq = (char**)pstr;
pp->prereq[0] = master->tag;
pp->prereq[1] = NULL;
@@ -249,21 +247,17 @@ update_redir (int type, struct prog *master, pid_t pid)
}
static struct prog *
-register_prog0 (struct component *comp, int index)
+register_prog0 (struct component *comp, unsigned index)
{
struct prog *newp;
- int i;
newp = xzalloc (sizeof (*newp));
newp->type = TYPE_COMPONENT;
newp->tag = comp->tag;
newp->pid = 0;
- newp->idx = index;
newp->facility = comp->facility;
newp->v.p.comp = comp;
- for (i = 0; comp->argv[i]; i++)
- ;
- newp->v.p.argc = i;
+ newp->v.p.idx = index;
newp->v.p.socket = -1;
if (comp->disabled)
newp->v.p.status = status_disabled;
@@ -280,7 +274,7 @@ register_prog0 (struct component *comp, int index)
void
register_prog (struct component *comp)
{
- register_prog0 (comp, numprog++);
+ register_prog0 (comp, numcomp++);
}
void
@@ -729,10 +723,12 @@ prog_start (struct prog *prog)
if (debug_level >= 1)
{
int i;
+ struct component *comp = prog->v.p.comp;
+
logmsg_printf (LOG_DEBUG, "executing");
- for (i = 0; i < prog->v.p.argc; i++)
+ for (i = 0; i < comp->argc; i++)
logmsg_printf (LOG_DEBUG, " %s",
- quotearg (prog->v.p.comp->argv[i]));
+ quotearg (comp->argv[i]));
logmsg_printf (LOG_DEBUG, "\n");
}
@@ -951,7 +947,7 @@ print_dep (struct prog *prog)
unsigned n;
logmsg_printf (LOG_NOTICE, "%s -> ", prog->tag);
- for (n = depmap_first (depmap, depmap_col, prog->idx, &pos);
+ for (n = depmap_first (depmap, depmap_col, prog->v.p.idx, &pos);
n != (unsigned)-1;
n = depmap_next (depmap, pos))
{
@@ -984,18 +980,18 @@ progman_dump_depmap ()
printf ("%s:\n", _("Dependency map"));
printf (" ");
- for (i = 0; i < numprog; i++)
+ for (i = 0; i < numcomp; i++)
printf (" %2d", i);
printf ("\n");
- for (i = 0; i < numprog; i++)
+ for (i = 0; i < numcomp; i++)
{
printf ("%2d ", i);
- for (j = 0; j < numprog; j++)
+ for (j = 0; j < numcomp; j++)
printf (" %c ", depmap_isset (depmap, i, j) ? 'X' : ' ');
printf ("\n");
}
printf ("\n%s:\n", _("Legend"));
- for (i = 0; i < numprog; i++)
+ for (i = 0; i < numcomp; i++)
{
prog = prog_lookup_by_idx (i);
if (prog)
@@ -1013,7 +1009,7 @@ progman_build_depmap ()
fixup_prerequisites ();
rebuild_prerequisites ();
- depmap = depmap_alloc (numprog);
+ depmap = depmap_alloc (numcomp);
for (prog = proghead; prog; prog = prog->next)
if (prog->prereq)
{
@@ -1029,12 +1025,12 @@ progman_build_depmap ()
rc++;
}
else
- depmap_set (depmap, prog->idx, dep->idx);
+ depmap_set (depmap, prog->v.p.idx, dep->v.p.idx);
}
}
dp = depmap_copy (depmap);
depmap_tc (dp);
- for (i = 0; i < numprog; i++)
+ for (i = 0; i < numcomp; i++)
if (depmap_isset (dp, i, i))
{
prog = prog_lookup_by_idx (i);
@@ -1252,7 +1248,7 @@ prog_stop_dependents (struct prog *prog)
int warned = 0;
prog_stop_redirectors (prog);
- for (n = depmap_first (depmap, depmap_row, prog->idx, &pos);
+ for (n = depmap_first (depmap, depmap_row, prog->v.p.idx, &pos);
n != (unsigned)-1;
n = depmap_next (depmap, pos))
{
@@ -1865,7 +1861,7 @@ progman_dump_stats (const char *filename)
fprintf (fp, _("[listener]"));
else
fprintf (fp, _("[not running]"));
- for (i = 0; i < prog->v.p.argc; i++)
+ for (i = 0; i < prog->v.p.comp->argc; i++)
fprintf (fp, " %s", quotearg (prog->v.p.comp->argv[i]));
fputc ('\n', fp);
break;

Return to:

Send suggestions and report system problems to the System administrator.