aboutsummaryrefslogtreecommitdiff
path: root/src/sysvinit.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2016-02-13 23:55:47 +0200
committerSergey Poznyakoff <gray@gnu.org>2016-02-14 00:05:33 +0200
commit0a5eb4f65a20d37f2051dce8816485dd219fb735 (patch)
treeeadff6490ebf734431c354ac1ba40a4a8537fcb0 /src/sysvinit.c
parentc9581808b72ff25623c87cf49c471ce7f017985d (diff)
downloadpies-0a5eb4f65a20d37f2051dce8816485dd219fb735.tar.gz
pies-0a5eb4f65a20d37f2051dce8816485dd219fb735.tar.bz2
Fix handling of wait components
* src/pies.h (PIES_COMP_WAIT): Remove. (PIES_COMP_MASK): Save one bit. (PIES_CHLD_NONE, PIES_CHLD_CLEANUP) (PIES_CHLD_WAKEUP): New constants. (pies_schedule_children): New proto. (sysvinit_runlevel_setup): Change signature. * src/pies.c (children_cleanup, got_alarm): Merge into single static variable children_op. All uses updated. (pies_schedule_children): New function. (sig_handler): Update (main): Don't call ctl_open for init process. It is done by inittrans after transition from boot to normal state. Update to use pies_schedule_children. * src/prog.h (IS_ACTIVE_COMPONENT): New macro. * src/progman.c (prog_start): Don't modify prog->v.p.wait. (progman_wake_sleeping): Start usual components only after all "wait" components have terminated. (progman_cleanup): If a "wait" component has terminated, request PIES_CHLD_WAKEUP. * src/sysvinit.c (enstate) <wait>: Remove. (enablecomp): Update. (runlevel_setup_prog): Set prog->v.p.wait. (sysvinit_runlevel_setup): Take only one parameter. (inittrans): Remove "wait" and the related mess. Call ctl_open after transition boot -> normal.
Diffstat (limited to 'src/sysvinit.c')
-rw-r--r--src/sysvinit.c59
1 files changed, 19 insertions, 40 deletions
diff --git a/src/sysvinit.c b/src/sysvinit.c
index c9447ff..2d0671c 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -212,7 +212,6 @@ runlevel_index (int n)
struct enstate
{
int mask;
- int wait;
};
static int
@@ -249,27 +248,21 @@ enablecomp (struct prog *prog, void *data)
case pies_comp_powerfailnow:
case pies_comp_kbrequest:
return s && (s->mask & PIES_COMP_MASK (comp->mode));
+
default:
break;
}
}
+ if (!comp->runlevels)
+ return -1;
+
if (!strchr (comp->runlevels, runlevel))
return 0;
if (prog->v.p.status == status_finished)
return -1;
- if (s && s->mask & PIES_COMP_WAIT)
- {
- if (comp->mode == pies_comp_wait)
- {
- s->wait = 1;
- return 1;
- }
- return 0;
- }
-
return 1;
}
@@ -285,26 +278,22 @@ runlevel_setup_prog (struct prog *prog, void *data)
prog->v.p.comp->flags &= ~CF_DISABLED;
else
prog->v.p.comp->flags |= CF_DISABLED;
- debug (2, ("%s: %s", prog_tag (prog),
+ prog->v.p.wait = is_comp_wait (prog->v.p.comp);
+ debug (2, ("%s: %s%s", prog_tag (prog),
prog->v.p.comp->flags & CF_DISABLED ?
- "disabled" : "enabled"));
+ "disabled" : "enabled",
+ !(prog->v.p.comp->flags & CF_DISABLED) && prog->v.p.wait
+ ? " (wait)" : ""));
}
return 0;
}
void
-sysvinit_runlevel_setup (int mask, int *wait)
+sysvinit_runlevel_setup (int mask)
{
struct enstate s;
s.mask = mask;
- if (wait)
- {
- s.mask |= PIES_COMP_WAIT;
- s.wait = *wait;
- }
progman_foreach (runlevel_setup_prog, &s);
- if (wait)
- *wait = s.wait;
}
static int
@@ -706,7 +695,7 @@ sysvinit_begin ()
console_stty ();
setsid ();
envsetup ();
- sysvinit_runlevel_setup (PIES_COMP_DEFAULT, NULL);
+ sysvinit_runlevel_setup (PIES_COMP_DEFAULT);
add_extra_sigv (sigv, ARRAY_SIZE (sigv));
sysvinit_sysdep_begin ();
}
@@ -743,7 +732,6 @@ inittrans ()
int newlevel = 0;
enum boot_state newstate;
int trans = 0;
- static int wait = 0;
if (progman_waiting_p ())
/* Noting to do if there are processes left in the previous runlevel */
@@ -763,7 +751,6 @@ inittrans ()
boot_state_name[newstate]));
boot_state = newstate;
trans = 1;
- wait = 0;
}
switch (boot_state)
@@ -779,8 +766,11 @@ inittrans ()
case normal:
newlevel = dfl_level ? dfl_level : getinitdefault ();
if (trans)
- /* boot -> normal */
- create_fifo ();
+ {
+ /* boot -> normal */
+ create_fifo ();
+ ctl_open ();
+ }
}
if (newlevel && newlevel != runlevel)
{
@@ -791,22 +781,14 @@ inittrans ()
mf_proctitle_format ("init [%c]", newlevel);
runlevel = newlevel;
trans = 1;
- wait = 0;
}
- if (wait)
- trans = 1;
+
if (trans)
{
int sig;
envsetup ();
- if (wait == 0)
- {
- sysvinit_runlevel_setup (PIES_COMP_DEFAULT, &wait);
- if (wait)
- return 1;
- }
- sysvinit_runlevel_setup (PIES_COMP_DEFAULT, NULL);
+ sysvinit_runlevel_setup (PIES_COMP_DEFAULT);
/* Stop disabled programs */
sig = SIGTERM;
@@ -817,9 +799,6 @@ inittrans ()
progman_foreach (terminate_disabled, &sig);
progman_wait_until (running_disabled, NULL);
}
-
- /* Clear the wait flag */
- wait = 0;
}
return trans;
}
@@ -1147,7 +1126,7 @@ powerfailcmd (int power_stat)
| PIES_COMP_MASK (pies_comp_powerwait);
}
- sysvinit_runlevel_setup (mask, NULL);
+ sysvinit_runlevel_setup (mask);
}
void

Return to:

Send suggestions and report system problems to the System administrator.