diff options
-rw-r--r-- | src/pies.c | 54 | ||||
-rw-r--r-- | src/pies.h | 11 | ||||
-rw-r--r-- | src/prog.h | 2 | ||||
-rw-r--r-- | src/progman.c | 20 | ||||
-rw-r--r-- | src/sysvinit.c | 59 |
5 files changed, 67 insertions, 79 deletions
@@ -1536,7 +1536,7 @@ pies_reload (void) | |||
1536 | { | 1536 | { |
1537 | component_config_commit (); | 1537 | component_config_commit (); |
1538 | if (init_process) | 1538 | if (init_process) |
1539 | sysvinit_runlevel_setup (PIES_COMP_DEFAULT, NULL); | 1539 | sysvinit_runlevel_setup (PIES_COMP_DEFAULT); |
1540 | progman_create_sockets (); | 1540 | progman_create_sockets (); |
1541 | progman_start (); | 1541 | progman_start (); |
1542 | } | 1542 | } |
@@ -1549,9 +1549,8 @@ static struct config_syntax *current_syntax = &config_syntax_tab[CONF_PIES]; | |||
1549 | #include "cmdline.h" | 1549 | #include "cmdline.h" |
1550 | 1550 | ||
1551 | 1551 | ||
1552 | int action = ACTION_CONT; | 1552 | static int action = ACTION_CONT; |
1553 | int children_cleanup = 0; | 1553 | static int children_op = PIES_CHLD_NONE; |
1554 | int got_alarm = 0; | ||
1555 | 1554 | ||
1556 | void | 1555 | void |
1557 | pies_schedule_action (int act) | 1556 | pies_schedule_action (int act) |
@@ -1559,6 +1558,12 @@ pies_schedule_action (int act) | |||
1559 | action = act; | 1558 | action = act; |
1560 | } | 1559 | } |
1561 | 1560 | ||
1561 | void | ||
1562 | pies_schedule_children (int op) | ||
1563 | { | ||
1564 | children_op |= op; | ||
1565 | } | ||
1566 | |||
1562 | RETSIGTYPE | 1567 | RETSIGTYPE |
1563 | sig_handler (int sig) | 1568 | sig_handler (int sig) |
1564 | { | 1569 | { |
@@ -1567,7 +1572,7 @@ sig_handler (int sig) | |||
1567 | switch (sig) | 1572 | switch (sig) |
1568 | { | 1573 | { |
1569 | case SIGCHLD: | 1574 | case SIGCHLD: |
1570 | children_cleanup = 1; | 1575 | pies_schedule_children (PIES_CHLD_CLEANUP); |
1571 | break; | 1576 | break; |
1572 | 1577 | ||
1573 | case SIGINT: | 1578 | case SIGINT: |
@@ -1588,7 +1593,7 @@ sig_handler (int sig) | |||
1588 | break; | 1593 | break; |
1589 | 1594 | ||
1590 | case SIGALRM: | 1595 | case SIGALRM: |
1591 | got_alarm = 1; | 1596 | pies_schedule_children (PIES_CHLD_WAKEUP); |
1592 | break; | 1597 | break; |
1593 | } | 1598 | } |
1594 | } | 1599 | } |
@@ -2150,9 +2155,7 @@ main (int argc, char **argv) | |||
2150 | diag_setup (DIAG_TO_SYSLOG); | 2155 | diag_setup (DIAG_TO_SYSLOG); |
2151 | } | 2156 | } |
2152 | 2157 | ||
2153 | if (init_process) | 2158 | if (!init_process) |
2154 | ctl_open (); | ||
2155 | else | ||
2156 | { | 2159 | { |
2157 | if (ctl_open ()) | 2160 | if (ctl_open ()) |
2158 | exit (EX_UNAVAILABLE); | 2161 | exit (EX_UNAVAILABLE); |
@@ -2173,10 +2176,10 @@ main (int argc, char **argv) | |||
2173 | { | 2176 | { |
2174 | if (init_process && inittrans ()) | 2177 | if (init_process && inittrans ()) |
2175 | { | 2178 | { |
2176 | got_alarm = 1; | 2179 | pies_schedule_children (PIES_CHLD_WAKEUP); |
2177 | action = ACTION_CONT; | 2180 | action = ACTION_CONT; |
2178 | } | 2181 | } |
2179 | else if (!children_cleanup) | 2182 | else if (children_op == PIES_CHLD_NONE) |
2180 | pies_pause (); | 2183 | pies_pause (); |
2181 | switch (action) | 2184 | switch (action) |
2182 | { | 2185 | { |
@@ -2190,7 +2193,7 @@ main (int argc, char **argv) | |||
2190 | 2193 | ||
2191 | case ACTION_RELOAD: | 2194 | case ACTION_RELOAD: |
2192 | pies_reload (); | 2195 | pies_reload (); |
2193 | got_alarm = 1; | 2196 | pies_schedule_children (PIES_CHLD_WAKEUP); |
2194 | action = ACTION_CONT; | 2197 | action = ACTION_CONT; |
2195 | break; | 2198 | break; |
2196 | 2199 | ||
@@ -2204,38 +2207,31 @@ main (int argc, char **argv) | |||
2204 | 2207 | ||
2205 | case ACTION_CTRLALTDEL: | 2208 | case ACTION_CTRLALTDEL: |
2206 | debug (1, ("ctrl-alt-del")); | 2209 | debug (1, ("ctrl-alt-del")); |
2207 | sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_ctrlaltdel), | 2210 | sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_ctrlaltdel)); |
2208 | NULL); | 2211 | pies_schedule_children (PIES_CHLD_WAKEUP); |
2209 | got_alarm = 1; | ||
2210 | action = ACTION_CONT; | 2212 | action = ACTION_CONT; |
2211 | break; | 2213 | break; |
2212 | 2214 | ||
2213 | case ACTION_KBREQUEST: | 2215 | case ACTION_KBREQUEST: |
2214 | debug (1, ("kbrequest")); | 2216 | debug (1, ("kbrequest")); |
2215 | sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_kbrequest), | 2217 | sysvinit_runlevel_setup (PIES_COMP_MASK (pies_comp_kbrequest)); |
2216 | NULL); | 2218 | pies_schedule_children (PIES_CHLD_WAKEUP); |
2217 | got_alarm = 1; | ||
2218 | action = ACTION_CONT; | 2219 | action = ACTION_CONT; |
2219 | break; | 2220 | break; |
2220 | 2221 | ||
2221 | case ACTION_POWER: | 2222 | case ACTION_POWER: |
2222 | debug (1, ("SIGPWR")); | 2223 | debug (1, ("SIGPWR")); |
2223 | sysvinit_power (); | 2224 | sysvinit_power (); |
2224 | got_alarm = 1; | 2225 | pies_schedule_children (PIES_CHLD_WAKEUP); |
2225 | action = ACTION_CONT; | 2226 | action = ACTION_CONT; |
2226 | } | 2227 | } |
2227 | if (action == ACTION_CONT) | 2228 | if (action == ACTION_CONT) |
2228 | { | 2229 | { |
2229 | if (children_cleanup) | 2230 | if (children_op & PIES_CHLD_CLEANUP) |
2230 | { | 2231 | progman_cleanup (0); |
2231 | children_cleanup = 0; | 2232 | if (children_op & PIES_CHLD_WAKEUP) |
2232 | progman_cleanup (0); | 2233 | progman_wake_sleeping (1); |
2233 | } | 2234 | children_op = PIES_CHLD_NONE; |
2234 | if (got_alarm) | ||
2235 | { | ||
2236 | progman_wake_sleeping (1); | ||
2237 | got_alarm = 0; | ||
2238 | } | ||
2239 | } | 2235 | } |
2240 | } | 2236 | } |
2241 | while (init_process || action == ACTION_CONT); | 2237 | while (init_process || action == ACTION_CONT); |
@@ -180,8 +180,7 @@ enum pies_comp_mode | |||
180 | }; | 180 | }; |
181 | 181 | ||
182 | #define PIES_COMP_DEFAULT 0 | 182 | #define PIES_COMP_DEFAULT 0 |
183 | #define PIES_COMP_WAIT 0x01 | 183 | #define PIES_COMP_MASK(m) (1 << ((m))) |
184 | #define PIES_COMP_MASK(m) (1 << ((m)+1)) | ||
185 | 184 | ||
186 | #define CF_DISABLED 0x001 /* The componenet is disabled */ | 185 | #define CF_DISABLED 0x001 /* The componenet is disabled */ |
187 | #define CF_PRECIOUS 0x002 /* The component is precious (should not | 186 | #define CF_PRECIOUS 0x002 /* The component is precious (should not |
@@ -317,6 +316,12 @@ void free_redirector (struct redirector *rp); | |||
317 | void pies_schedule_action (int act); | 316 | void pies_schedule_action (int act); |
318 | void free_action (struct action *act); | 317 | void free_action (struct action *act); |
319 | 318 | ||
319 | #define PIES_CHLD_NONE 0 | ||
320 | #define PIES_CHLD_CLEANUP 0x01 | ||
321 | #define PIES_CHLD_WAKEUP 0x02 | ||
322 | |||
323 | void pies_schedule_children (int op); | ||
324 | |||
320 | void register_prog (struct component *comp); | 325 | void register_prog (struct component *comp); |
321 | int progman_waiting_p (void); | 326 | int progman_waiting_p (void); |
322 | void progman_start (void); | 327 | void progman_start (void); |
@@ -512,7 +517,7 @@ int console_open (int mode); | |||
512 | int telinit (const char *arg); | 517 | int telinit (const char *arg); |
513 | int inittab_parse (const char *file); | 518 | int inittab_parse (const char *file); |
514 | int sysvinit_sigtrans (int sig, int *pact); | 519 | int sysvinit_sigtrans (int sig, int *pact); |
515 | void sysvinit_runlevel_setup (int mask, int *wait); | 520 | void sysvinit_runlevel_setup (int mask); |
516 | void sysvinit_sysdep_begin (void); | 521 | void sysvinit_sysdep_begin (void); |
517 | void sysvinit_power (void); | 522 | void sysvinit_power (void); |
518 | 523 | ||
@@ -81,6 +81,8 @@ struct prog | |||
81 | }; | 81 | }; |
82 | 82 | ||
83 | #define IS_COMPONENT(p) ((p)->type == TYPE_COMPONENT) | 83 | #define IS_COMPONENT(p) ((p)->type == TYPE_COMPONENT) |
84 | #define IS_ACTIVE_COMPONENT(prog) \ | ||
85 | (IS_COMPONENT(prog) && !((prog)->v.p.comp->flags & CF_DISABLED)) | ||
84 | 86 | ||
85 | struct prog *progman_locate (const char *name); | 87 | struct prog *progman_locate (const char *name); |
86 | int progman_foreach (int (*filter) (struct prog *, void *data), void *data); | 88 | int progman_foreach (int (*filter) (struct prog *, void *data), void *data); |
diff --git a/src/progman.c b/src/progman.c index 29b5331..8a5187c 100644 --- a/src/progman.c +++ b/src/progman.c | |||
@@ -1050,7 +1050,6 @@ prog_start (struct prog *prog) | |||
1050 | } | 1050 | } |
1051 | return; | 1051 | return; |
1052 | } | 1052 | } |
1053 | prog->v.p.wait = is_comp_wait (prog->v.p.comp); | ||
1054 | } | 1053 | } |
1055 | 1054 | ||
1056 | /* This call returns 1 in two cases: Either prog is marked as disabled, | 1055 | /* This call returns 1 in two cases: Either prog is marked as disabled, |
@@ -1541,14 +1540,20 @@ progman_wake_sleeping (int onalrm) | |||
1541 | struct prog *prog; | 1540 | struct prog *prog; |
1542 | time_t now = time (NULL); | 1541 | time_t now = time (NULL); |
1543 | 1542 | ||
1544 | if (progman_waiting_p ()) | 1543 | debug (1, (_("checking for components to start"))); |
1545 | /* Noting to do if there are processes left in the previous runlevel */ | ||
1546 | return; | ||
1547 | 1544 | ||
1548 | debug (1, (_("managing sleeping/stopping components"))); | 1545 | for (prog = proghead; prog; prog = prog->next) |
1546 | { | ||
1547 | if (IS_ACTIVE_COMPONENT (prog) && prog->v.p.wait) | ||
1548 | { | ||
1549 | if (prog->v.p.status != status_running) | ||
1550 | prog_start (prog); | ||
1551 | return; | ||
1552 | } | ||
1553 | } | ||
1549 | 1554 | ||