fuzzy dependency ordering should be started, starting, stopped whilst checking runlevel, bootlevel, any at each stage.
This commit is contained in:
parent
9b1cb4e246
commit
bf8f0da921
@ -271,7 +271,7 @@ get_provided(const RC_DEPINFO *depinfo, const char *runlevel, int options)
|
|||||||
return providers;
|
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. */
|
* runlevel and bootlevel. If we starting then check cold-plugged too. */
|
||||||
if (options & RC_DEP_STRICT || options & RC_DEP_START) {
|
if (options & RC_DEP_STRICT || options & RC_DEP_START) {
|
||||||
TAILQ_FOREACH(service, dt->services, entries)
|
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.
|
/* OK, we're not strict or there were no services in our runlevel.
|
||||||
This is now where the logic gets a little fuzzy :)
|
* This is now where the logic gets a little fuzzy :)
|
||||||
If there is >1 running service then we return NULL.
|
* If there is >1 running service then we return NULL.
|
||||||
We do this so we don't hang around waiting for inactive services and
|
* 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.
|
* our need has already been satisfied as it's not strict.
|
||||||
We apply this to our runlevel, coldplugged services, then bootlevel
|
* We apply this to these states in order:-
|
||||||
and finally any running.*/
|
* started, starting | stopping | inactive, stopped
|
||||||
|
* Our sub preference in each of these is in order:-
|
||||||
|
* runlevel, coldplugged, bootlevel, any
|
||||||
|
*/
|
||||||
#define DO \
|
#define DO \
|
||||||
if (TAILQ_FIRST(providers)) { \
|
if (TAILQ_FIRST(providers)) { \
|
||||||
if (TAILQ_NEXT(TAILQ_FIRST(providers), entries)) { \
|
if (TAILQ_NEXT(TAILQ_FIRST(providers), entries)) { \
|
||||||
@ -300,45 +303,35 @@ get_provided(const RC_DEPINFO *depinfo, const char *runlevel, int options)
|
|||||||
return providers; \
|
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))
|
if (get_provided1(runlevel, providers, dt, runlevel, false, RC_SERVICE_STARTED))
|
||||||
{ DO }
|
{ 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))
|
if (get_provided1(runlevel, providers, dt, NULL, true, RC_SERVICE_STARTED))
|
||||||
{ DO }
|
{ DO }
|
||||||
if (get_provided1(runlevel, providers, dt, NULL, true, RC_SERVICE_STARTING))
|
if (bootlevel && strcmp(runlevel, bootlevel) != 0 &&
|
||||||
return providers;
|
get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STARTED))
|
||||||
|
|
||||||
/* 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))
|
|
||||||
{ DO }
|
{ DO }
|
||||||
|
|
||||||
/* Check manually started */
|
|
||||||
if (get_provided1(runlevel, providers, dt, NULL, false, RC_SERVICE_STARTED))
|
if (get_provided1(runlevel, providers, dt, NULL, false, RC_SERVICE_STARTED))
|
||||||
{ DO }
|
{ 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))
|
if (get_provided1(runlevel, providers, dt, NULL, false, RC_SERVICE_STARTING))
|
||||||
return providers;
|
return providers;
|
||||||
|
|
||||||
/* Nothing started then. OK, lets get the stopped services */
|
/* Nothing started then. OK, lets get the stopped services */
|
||||||
if (get_provided1(runlevel, providers, dt, runlevel, false, RC_SERVICE_STOPPED))
|
if (get_provided1(runlevel, providers, dt, runlevel, false, RC_SERVICE_STOPPED))
|
||||||
return providers;
|
return providers;
|
||||||
|
if (get_provided1(runlevel, providers, dt, NULL, true, RC_SERVICE_STOPPED))
|
||||||
if (bootlevel && (strcmp(runlevel, bootlevel) != 0)
|
{ DO }
|
||||||
&& (get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STOPPED)))
|
if (bootlevel && (strcmp(runlevel, bootlevel) != 0) &&
|
||||||
|
get_provided1(runlevel, providers, dt, bootlevel, false, RC_SERVICE_STOPPED))
|
||||||
return providers;
|
return providers;
|
||||||
|
|
||||||
/* Still nothing? OK, list all services */
|
/* Still nothing? OK, list all services */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user