aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-06-10 15:19:46 +0000
committerRoy Marples <roy@marples.name>2008-06-10 15:19:46 +0000
commitbf8f0da92154f3295c7a84227294e776d179a2ad (patch)
tree8fa6e6c204cf62efdad479399f93a2bb068da9d1 /src
parent9b1cb4e24690fd08f6eac1579fa2f90c7dea5d33 (diff)
fuzzy dependency ordering should be started, starting, stopped whilst checking runlevel, bootlevel, any at each stage.
Diffstat (limited to 'src')
-rw-r--r--src/librc/librc-depend.c59
1 files changed, 26 insertions, 33 deletions
diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
index afb1c1cd..5b7de424 100644
--- a/src/librc/librc-depend.c
+++ b/src/librc/librc-depend.c
@@ -271,7 +271,7 @@ get_provided(const RC_DEPINFO *depinfo, const char *runlevel, int options)
return providers;
}
- /* If we're strict or startng, then only use what we have in our
+ /* If we're strict or starting, then only use what we have in our
* runlevel and bootlevel. If we starting then check cold-plugged too. */
if (options & RC_DEP_STRICT || options & RC_DEP_START) {
TAILQ_FOREACH(service, dt->services, entries)
@@ -285,12 +285,15 @@ get_provided(const RC_DEPINFO *depinfo, const char *runlevel, int options)
}
/* OK, we're not strict or there were no services in our runlevel.
- This is now where the logic gets a little fuzzy :)
- If there is >1 running service then we return NULL.
- We do this so we don't hang around waiting for inactive services and
- our need has already been satisfied as it's not strict.
- We apply this to our runlevel, coldplugged services, then bootlevel
- and finally any running.*/
+ * This is now where the logic gets a little fuzzy :)
+ * If there is >1 running service then we return NULL.
+ * We do this so we don't hang around waiting for inactive services and
+ * our need has already been satisfied as it's not strict.
+ * We apply this to these states in order:-
+ * started, starting | stopping | inactive, stopped
+ * Our sub preference in each of these is in order:-
+ * runlevel, coldplugged, bootlevel, any
+ */
#define DO \
if (TAILQ_FIRST(providers)) { \
if (TAILQ_NEXT(TAILQ_FIRST(providers), entries)) { \
@@ -300,45 +303,35 @@ get_provided(const RC_DEPINFO *depinfo, const char *runlevel, int options)
return providers; \
}
- /* Anything in the runlevel has to come first */
+ /* Anything running has to come first */
if (get_provided1(runlevel, providers, dt, runlevel, false, RC_SERVICE_STARTED))
{ DO }
- if (get_provided1(runlevel, providers, dt, runlevel, false, RC_SERVICE_STARTING))
- return providers;
- if (get_provided1(runlevel, providers, dt, runlevel, false, RC_SERVICE_STOPPED))
- return providers;
-
- /* Check coldplugged services */
if (get_provided1(runlevel, providers, dt, NULL, true, RC_SERVICE_STARTED))
{ DO }
- if (get_provided1(runlevel, providers, dt, NULL, true, RC_SERVICE_STARTING))
- return providers;
-
- /* Check bootlevel if we're not in it */
- if (bootlevel && strcmp(runlevel, bootlevel) != 0)
- {
- if (get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STARTED))
- { DO }
- if (get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STARTING))
- return providers;
- }
-
- /* Check coldplugged services */
- if (get_provided1(runlevel, providers, dt, NULL, true, RC_SERVICE_STOPPED))
+ if (bootlevel && strcmp(runlevel, bootlevel) != 0 &&
+ get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STARTED))
{ DO }
-
- /* Check manually started */
if (get_provided1(runlevel, providers, dt, NULL, false, RC_SERVICE_STARTED))
{ DO }
+
+ /* Check starting services */
+ if (get_provided1(runlevel, providers, dt, runlevel, false, RC_SERVICE_STARTING))
+ return providers;
+ if (get_provided1(runlevel, providers, dt, NULL, true, RC_SERVICE_STARTING))
+ return providers;
+ if (bootlevel && strcmp(runlevel, bootlevel) != 0 &&
+ get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STARTING))
+ return providers;
if (get_provided1(runlevel, providers, dt, NULL, false, RC_SERVICE_STARTING))
return providers;
/* Nothing started then. OK, lets get the stopped services */
if (get_provided1(runlevel, providers, dt, runlevel, false, RC_SERVICE_STOPPED))
return providers;
-
- if (bootlevel && (strcmp(runlevel, bootlevel) != 0)
- && (get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STOPPED)))
+ if (get_provided1(runlevel, providers, dt, NULL, true, RC_SERVICE_STOPPED))
+ { DO }
+ if (bootlevel && (strcmp(runlevel, bootlevel) != 0) &&
+ get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STOPPED))
return providers;
/* Still nothing? OK, list all services */