[Initng-svn] r2988 - in initng: plugins/daemon plugins/service src
svn at initng.thinktux.net
svn at initng.thinktux.net
Tue Feb 14 09:50:42 CET 2006
Author: jimmy
Date: Tue Feb 14 09:50:41 2006
New Revision: 2988
Modified:
initng/plugins/daemon/initng_daemon.c
initng/plugins/service/initng_service.c
initng/src/initng_depend.c
Log:
Move some more dep logic into initng_depend.c
Modified: initng/plugins/daemon/initng_daemon.c
==============================================================================
--- initng/plugins/daemon/initng_daemon.c (original)
+++ initng/plugins/daemon/initng_daemon.c Tue Feb 14 09:50:41 2006
@@ -306,7 +306,7 @@
/* This are run, when initng wants to start a daemon */
static int start_DAEMON(active_db_h * daemon_to_start)
{
- W_("Starting daemon %s.\n", daemon_to_start->name);
+ D_("Starting daemon %s.\n", daemon_to_start->name);
/* mark it WAITING_FOR_START_DEP and wait */
if (!initng_common_mark_service(daemon_to_start, &DAEMON_START_MARKED))
{
@@ -321,13 +321,22 @@
/* This are run, when initng wants to stop a daemon */
static int stop_DAEMON(active_db_h * daemon)
{
+ /* Stopp all services dependeing on this service */
+ if(initng_depend_stop_deps(daemon)!=TRUE)
+ return(FALSE);
+
/* set stopping */
if (!initng_common_mark_service(daemon, &DAEMON_STOP_MARKED))
+ {
+ W_("mark_service DAEMON_STOP_MARKED failed for daemon %s.\n", daemon->name);
return (FALSE);
-
+ }
+
+ /* return happily */
return (TRUE);
}
+
/*
* ############################################################################
* # PLUGIN INITIATORS #
@@ -462,37 +471,8 @@
static void handle_DAEMON_WAITING_FOR_START_DEP(active_db_h * daemon)
{
- active_db_h *current = NULL;
-
assert(daemon);
- /*
- * Check so all deps, that needs daemon, is up.
- */
- while_active_db(current)
- {
- if (current == daemon)
- continue;
-
- /* if current is not one that it depends on continue */
- if (initng_depend(daemon, current) == FALSE)
- continue;
-
- /* if service dep on is starting, wait a bit */
- if (IS_STARTING(current))
- return;
-
- /* if its not starting or up, mark it DAEMON_START_DEPS_FAILED */
- if (!IS_UP(current))
- {
- D_("daemon %s depending on daemon %s status %s, aborting.\n",
- daemon->name, current->name,
- current->current_state->state_name);
- initng_common_mark_service(daemon, &DAEMON_START_DEPS_FAILED);
- return;
- }
- }
-
/* this checks with external plug-ins, if its ok to start this service now */
if(initng_depend_start_dep_met(daemon)!=TRUE)
return;
@@ -512,43 +492,7 @@
static void handle_DAEMON_WAITING_FOR_STOP_DEP(active_db_h * daemon)
{
- active_db_h *current = NULL;
-
assert(daemon);
- D_("handle_DAEMON_WAITING_FOR_STOP_DEP (%s)!\n", daemon->name);
- /*
- * Check so all deps, that needs daemon, is down.
- * if there are daemons depending on this one still running, return false and still try
- */
- while_active_db(current)
- {
- if (current == daemon)
- continue;
-
- /* Does daemon depends on current ?? */
- if (initng_depend(current, daemon) == FALSE)
- continue;
-
- /* if its done, this is perfect */
- if (IS_DOWN(current))
- continue;
-
- /* If the dep is failed, continue */
- if (IS_FAILED(current))
- continue;
-
- /* else RETURN */
- D_("still waiting for %s state %s\n", current->name,
- current->current_state->state_name);
-
- /* if its still up */
- if (IS_UP(current))
- {
- /* stop the daemon again */
- initng_handler_stop_service(current);
- }
- return;
- }
/* check with other plug-ins, if it is ok to stop this service now */
if(initng_depend_stop_dep_met(daemon)!=TRUE)
Modified: initng/plugins/service/initng_service.c
==============================================================================
--- initng/plugins/service/initng_service.c (original)
+++ initng/plugins/service/initng_service.c Tue Feb 14 09:50:41 2006
@@ -162,19 +162,21 @@
/* This are run, when initng wants to start a service */
-static int start_SERVICE(active_db_h * service_to_start)
+static int start_SERVICE(active_db_h * service)
{
/* Start our dependencies */
- if(initng_depend_start_deps(service_to_start)!=TRUE)
+ if(initng_depend_start_deps(service)!=TRUE)
return(FALSE);
/* mark it WAITING_FOR_START_DEP and wait */
- if (!initng_common_mark_service(service_to_start, &SERVICE_START_MARKED))
+ if (!initng_common_mark_service(service, &SERVICE_START_MARKED))
{
W_("mark_service SERVICE_START_MARKED failed for service %s\n",
- service_to_start->name);
+ service->name);
return (FALSE);
}
+
+ /* return happily */
return (TRUE);
}
@@ -182,10 +184,18 @@
/* This are run, when initng wants to stop a service */
static int stop_SERVICE(active_db_h * service)
{
+ /* Stopp all services dependeing on this service */
+ if(initng_depend_stop_deps(service)!=TRUE)
+ return(FALSE);
+
/* set stopping */
if (!initng_common_mark_service(service, &SERVICE_STOP_MARKED))
+ {
+ W_("mark_service SERVICE_STOP_MARKED failed for service %s.\n", service->name);
return (FALSE);
-
+ }
+
+ /* return happily */
return (TRUE);
}
@@ -281,37 +291,8 @@
static void handle_SERVICE_WAITING_FOR_START_DEP(active_db_h * service)
{
- active_db_h *current = NULL;
-
assert(service);
- /*
- * Check so all deps, that needs service, is up.
- */
- while_active_db(current)
- {
- if (current == service)
- continue;
-
- /* if current is not one that it depends on continue */
- if (initng_depend(service, current) == FALSE)
- continue;
-
- /* if service dep on is starting, wait a bit */
- if (IS_STARTING(current))
- return;
-
- /* if its not starting or up, mark it SERVICE_START_DEPS_FAILED */
- if (!IS_UP(current))
- {
- D_("service %s depending on service %s status %s, aborting.\n",
- service->name, current->name,
- current->current_state->state_name);
- initng_common_mark_service(service, &SERVICE_START_DEPS_FAILED);
- return;
- }
- }
-
/* this checks with external plug-ins, if its ok to start this service now */
if(initng_depend_start_dep_met(service)!=TRUE)
return;
@@ -331,43 +312,7 @@
static void handle_SERVICE_WAITING_FOR_STOP_DEP(active_db_h * service)
{
- active_db_h *current = NULL;
-
assert(service);
- D_("handle_SERVICE_WAITING_FOR_STOP_DEP (%s)!\n", service->name);
- /*
- * Check so all deps, that needs service, is down.
- * if there are services depending on this one still running, return false and still try
- */
- while_active_db(current)
- {
- if (current == service)
- continue;
-
- /* Does service depends on current ?? */
- if (initng_depend(current, service) == FALSE)
- continue;
-
- /* if its done, this is perfect */
- if (IS_DOWN(current))
- continue;
-
- /* If the dep is failed, continue */
- if (IS_FAILED(current))
- continue;
-
- /* else RETURN */
- D_("still waiting for %s state %s\n", current->name,
- current->current_state->state_name);
-
- /* if its still up */
- if (IS_UP(current))
- {
- /* stop the service again */
- initng_handler_stop_service(current);
- }
- return;
- }
/* check with other plug-ins, if it is ok to stop this service now */
if(initng_depend_stop_dep_met(service)!=TRUE)
Modified: initng/src/initng_depend.c
==============================================================================
--- initng/src/initng_depend.c (original)
+++ initng/src/initng_depend.c Tue Feb 14 09:50:41 2006
@@ -152,7 +152,21 @@
int initng_depend_stop_deps(active_db_h * service)
{
- F_("Now written yet.\n");
+ active_db_h *current = NULL;
+ active_db_h *safe = NULL;
+
+ /* also stop all service depending on service_to_stop */
+ while_active_db_safe(current, safe)
+ {
+ /* Dont mind stop itself */
+ if (current == service)
+ continue;
+
+ /* if current depends on the one we are stopping */
+ if (initng_depend_deep(current, service) == TRUE)
+ initng_handler_stop_service(current);
+ }
+
return(TRUE);
}
@@ -164,7 +178,37 @@
int initng_depend_start_dep_met(active_db_h * service)
{
s_call *current, *s = NULL;
+ active_db_h *currentA=NULL;
int ret;
+
+ /*
+ * Check so all deps, that needs service, is up.
+ */
+ while_active_db(currentA)
+ {
+ if (currentA == service)
+ continue;
+
+ /* if current is not one that it depends on continue */
+ if (initng_depend_deep(service, currentA) == FALSE)
+ continue;
+
+ /* if service dep on is starting, wait a bit */
+ if (IS_STARTING(currentA))
+ return(FALSE);
+
+ /* if service failed, return that */
+ if (IS_FAILED(currentA))
+ return(FAIL);
+
+ /* if its not starting or up, return FAIL */
+ if (!IS_UP(currentA))
+ {
+ initng_handler_start_service(currentA);
+ return(FALSE);
+ }
+ }
+
/* run the global plugin dep check */
while_list_safe(current, &g.START_DEP_MET, s)
@@ -183,7 +227,42 @@
int initng_depend_stop_dep_met(active_db_h * service)
{
s_call *current, *s = NULL;
+ active_db_h *currentA = NULL;
int ret;
+
+ /*
+ * Check so all deps, that needs service, is down.
+ * if there are services depending on this one still running, return false and still try
+ */
+ while_active_db(currentA)
+ {
+ if (currentA == service)
+ continue;
+
+ /* Does service depends on current ?? */
+ if (initng_depend(currentA, service) == FALSE)
+ continue;
+
+ /* if its done, this is perfect */
+ if (IS_DOWN(currentA))
+ continue;
+
+ /* If the dep is failed, continue */
+ if (IS_FAILED(currentA))
+ continue;
+
+ /* else RETURN */
+ D_("still waiting for %s state %s\n", currentA->name,
+ currentA->current_state->state_name);
+
+ /* if its still up */
+ if (IS_UP(currentA))
+ {
+ /* stop the service again, youst to make sure */
+ initng_handler_stop_service(currentA);
+ }
+ return(FALSE);
+ }
/* run the global plugin dep check */
while_list_safe(current, &g.STOP_DEP_MET, s)
@@ -245,3 +324,4 @@
return (TRUE);
}
+
More information about the Initng-svn
mailing list