[Initng-svn] r2950 - in initng: . plugins plugins/daemon
plugins/depend plugins/last plugins/service plugins/stcmd
plugins/unneeded src
svn at initng.thinktux.net
svn at initng.thinktux.net
Mon Feb 6 13:01:07 CET 2006
Author: jimmy
Date: Mon Feb 6 13:01:06 2006
New Revision: 2950
Removed:
initng/plugins/depend/
Modified:
initng/configure.in
initng/plugins/Makefile.am
initng/plugins/daemon/initng_daemon.c
initng/plugins/last/initng_last.c
initng/plugins/service/initng_service.c
initng/plugins/stcmd/initng_stcmd.c
initng/plugins/unneeded/initng_unneeded.c
initng/src/initng_active_db.c
initng/src/initng_active_db.h
initng/src/initng_common.c
initng/src/initng_control_command.c
initng/src/initng_depend.c
initng/src/initng_handler.c
initng/src/initng_static_process_types.c
initng/src/initng_static_service_types.c
initng/src/initng_static_states.c
Log:
A Lot of cleaups, still lots of work to do.
Modified: initng/configure.in
==============================================================================
--- initng/configure.in (original)
+++ initng/configure.in Mon Feb 6 13:01:06 2006
@@ -31,7 +31,7 @@
-Wundef \
-Wunused \
-Wcomment \
-#-Werror"
+-Werror"
#note: flags are hacked to get initial selinux support
# All set by -Wunused
Modified: initng/plugins/Makefile.am
==============================================================================
--- initng/plugins/Makefile.am (original)
+++ initng/plugins/Makefile.am Mon Feb 6 13:01:06 2006
@@ -37,10 +37,6 @@
SUBDIRS+=daemon_clean
endif
-if BUILD_DEPEND
- SUBDIRS+=depend
-endif
-
if BUILD_DLLAUNCH
SUBDIRS+=dllaunch
endif
Modified: initng/plugins/daemon/initng_daemon.c
==============================================================================
--- initng/plugins/daemon/initng_daemon.c (original)
+++ initng/plugins/daemon/initng_daemon.c Mon Feb 6 13:01:06 2006
@@ -270,6 +270,9 @@
static void handle_DAEMON_START_MARKED(active_db_h * daemon)
{
+ /* start all our dependencys */
+ initng_depend_start_deps(daemon);
+
/* TODO, add the dependecy start code here */
initng_common_mark_service(daemon, &DAEMON_WAITING_FOR_START_DEP);
@@ -298,7 +301,7 @@
continue;
/* if current is not one that it depends on continue */
- if (initng_active_db_dep_on(daemon, current) == FALSE)
+ if (initng_depend(daemon, current) == FALSE)
continue;
/* if servuce dep on is starting, wait a bit */
@@ -476,7 +479,7 @@
continue;
/* check that current needs daemon_stopped */
- if (initng_active_db_dep_on(current, daemon_stopped) == FALSE)
+ if (initng_depend(current, daemon_stopped) == FALSE)
continue;
/* dont stop a stopped daemon */
Modified: initng/plugins/last/initng_last.c
==============================================================================
--- initng/plugins/last/initng_last.c (original)
+++ initng/plugins/last/initng_last.c Mon Feb 6 13:01:06 2006
@@ -29,6 +29,7 @@
#include "../../src/initng_global.h"
#include "../../src/initng_plugin_hook.h"
#include "../../src/initng_common.h"
+#include "../../src/initng_depend.h"
#include "../../src/initng_toolbox.h"
#include "../../src/initng_static_data_id.h"
#include "../../src/initng_static_states.h"
@@ -72,7 +73,7 @@
/* TODO, use dep_on_deep */
/* if current need service that should be last */
- if (initng_active_db_dep_on_deep(current, service) == TRUE)
+ if (initng_depend_deep(current, service) == TRUE)
{
/* dont wait, becouse this wait is circular */
D_("Service %s depends on %s\n", service->name, current->name);
Modified: initng/plugins/service/initng_service.c
==============================================================================
--- initng/plugins/service/initng_service.c (original)
+++ initng/plugins/service/initng_service.c Mon Feb 6 13:01:06 2006
@@ -164,7 +164,9 @@
/* This are run, when initng wants to start a service */
static int start_SERVICE(active_db_h * service_to_start)
{
- /* TODO, start the deps here instead */
+ /* Start our dependencys */
+ if(initng_depend_start_deps(service_to_start)!=TRUE)
+ return(FALSE);
/* mark it WAITING_FOR_START_DEP and wait */
if (!initng_common_mark_service(service_to_start, &SERVICE_START_MARKED))
@@ -292,7 +294,7 @@
continue;
/* if current is not one that it depends on continue */
- if (initng_active_db_dep_on(service, current) == FALSE)
+ if (initng_depend(service, current) == FALSE)
continue;
/* if servuce dep on is starting, wait a bit */
@@ -310,6 +312,10 @@
}
}
+ /* this checks with external plugins, if its ok to start this service now */
+ if(initng_depend_start_dep_met(service)!=TRUE)
+ return;
+
/* if system is shuting down, dont start anything */
if (g.sys_state != STATE_STARTING && g.sys_state != STATE_UP)
{
@@ -363,6 +369,10 @@
return;
}
+ /* check with other plugins, if it is ok to stop this service now */
+ if(initng_depend_stop_dep_met(service)!=TRUE)
+ return;
+
/* ok, stopping deps are met */
initng_common_mark_service(service, &SERVICE_STOP_DEPS_MET);
}
@@ -446,7 +456,7 @@
continue;
/* check that current needs service_stopped */
- if (initng_active_db_dep_on(current, service_stopped) == FALSE)
+ if (initng_depend(current, service_stopped) == FALSE)
continue;
/* dont stop a stopped service */
Modified: initng/plugins/stcmd/initng_stcmd.c
==============================================================================
--- initng/plugins/stcmd/initng_stcmd.c (original)
+++ initng/plugins/stcmd/initng_stcmd.c Mon Feb 6 13:01:06 2006
@@ -50,6 +50,7 @@
#include "../../src/initng_string_tools.h"
#include "../../src/initng_static_states.h"
#include "../../src/initng_static_process_types.h"
+#include "../../src/initng_depend.h"
#include "../../src/initng_main.h"
#include "initng_stcmd.h"
@@ -535,7 +536,7 @@
while_active_db(current)
{
/* if that we are watching needs current */
- if (initng_active_db_dep_on(on, current) == TRUE)
+ if (initng_depend(on, current) == TRUE)
{
if (current->current_state && current->current_state->state_name)
{
@@ -564,7 +565,7 @@
while_active_db(current)
{
/* if that we are watching needs current */
- if (initng_active_db_dep_on_deep(on, current) == TRUE)
+ if (initng_depend_deep(on, current) == TRUE)
{
if (current->current_state && current->current_state->state_name)
{
@@ -594,7 +595,7 @@
while_active_db(current)
{
/* if current need the one we are watching */
- if (initng_active_db_dep_on(current, on) == TRUE)
+ if (initng_depend(current, on) == TRUE)
{
if (current->current_state && current->current_state->state_name)
{
@@ -624,7 +625,7 @@
while_active_db(current)
{
/* if current need the one we are watching */
- if (initng_active_db_dep_on_deep(current, on) == TRUE)
+ if (initng_depend_deep(current, on) == TRUE)
{
if (current->current_state && current->current_state->state_name)
{
Modified: initng/plugins/unneeded/initng_unneeded.c
==============================================================================
--- initng/plugins/unneeded/initng_unneeded.c (original)
+++ initng/plugins/unneeded/initng_unneeded.c Mon Feb 6 13:01:06 2006
@@ -46,6 +46,7 @@
#include "../../src/initng_plugin_callers.h"
#include "../../src/initng_global.h"
#include "../../src/initng_error.h"
+#include "../../src/initng_depend.h"
#include "../../src/initng_string_tools.h"
#include "../../src/initng_static_service_types.h"
@@ -88,7 +89,7 @@
continue;
/* if B needs A */
- if (initng_active_db_dep_on(B, A) == TRUE)
+ if (initng_depend(B, A) == TRUE)
{
needed = TRUE;
break;
Modified: initng/src/initng_active_db.c
==============================================================================
--- initng/src/initng_active_db.c (original)
+++ initng/src/initng_active_db.c Mon Feb 6 13:01:06 2006
@@ -40,6 +40,7 @@
#include "initng_plugin_callers.h"
#include "initng_string_tools.h"
#include "initng_static_states.h"
+#include "initng_depend.h"
/* ##### ACTIVE_DB_FIND_BY ######## */
@@ -324,81 +325,6 @@
/* ######### ACTIVE_DB_UTILS ############# */
-/*
- * active_db_dep_on:
- * Will check with all plugins and return TRUE
- * if service depends on check.
- */
-int initng_active_db_dep_on(active_db_h * service, active_db_h * check)
-{
- s_call *current, *s = NULL;
- int result = FALSE;
-
- assert(service);
- assert(check);
-
- if (service == check)
- return (FALSE);
-
- while_list_safe(current, &g.DEP_ON, s)
- {
- if ((result = (*current->c.dep_on_check) (service, check) == TRUE))
- break;
- }
- return result;
-}
-
-
-
-
-/*
- * A deeper deepfind.
- * Logic, we wanna make sure that depend check in a deeper level.
- * if daemon/smbd -> daemon/samba -> system/checkroot -> system/initial.
- * So should active_db_dep_on_deep(daemon/smbd, system/initial) == TRUE
- *
- * Sumary, does service depends on check?
- */
-static int active_db_dep_on_deep2(active_db_h * service, active_db_h * check,
- int *stack);
-int initng_active_db_dep_on_deep(active_db_h * service, active_db_h * check)
-{
- int stack = 0;
-
- return (active_db_dep_on_deep2(service, check, &stack));
-}
-
-static int active_db_dep_on_deep2(active_db_h * service, active_db_h * check,
- int *stack)
-{
- active_db_h *current = NULL;
- int result = FALSE;
-
- if (current == service)
- return (FALSE);
-
- /* if service depends on check, it also dep_on_deep's on check */
- /* this serves as an exit from the recusrion */
- if (initng_active_db_dep_on(service, check))
- return (TRUE);
-
- /* in case there is a circular dependency, break after 10 levels of recusrion */
- (*stack)++;
- if (*stack > 10)
- return (FALSE);
-
- /* loop over all services, if service depends on current, recursivly check if
- * current may depend (deep) on check */
- while_active_db(current)
- {
- if (initng_active_db_dep_on(service, current))
- {
- if ((result = active_db_dep_on_deep2(current, check, stack)))
- break;
- }
- }
- return result;
-}
/* compensate time */
void initng_active_db_compensate_time(time_t skew)
Modified: initng/src/initng_active_db.h
==============================================================================
--- initng/src/initng_active_db.h (original)
+++ initng/src/initng_active_db.h Mon Feb 6 13:01:06 2006
@@ -98,8 +98,8 @@
/* dependency check */
/* returns TRUE if service DEP ON check */
-int initng_active_db_dep_on(active_db_h * service, active_db_h * check);
-int initng_active_db_dep_on_deep(active_db_h * service, active_db_h * check);
+/*int initng_active_db_dep_on(active_db_h * service, active_db_h * check);
+int initng_active_db_dep_on_deep(active_db_h * service, active_db_h * check);*/
/* utils */
int initng_active_db_percent_started(void);
Modified: initng/src/initng_common.c
==============================================================================
--- initng/src/initng_common.c (original)
+++ initng/src/initng_common.c Mon Feb 6 13:01:06 2006
@@ -45,6 +45,7 @@
#include "initng_string_tools.h"
#include "initng_global.h"
#include "initng_static_states.h"
+#include "initng_depend.h"
/*
* this fuction walks thru the g.Argv, if it founds service name,
@@ -150,8 +151,8 @@
{
while_active_db(current)
{
- if (initng_active_db_dep_on_deep(a_new, current)
- && initng_active_db_dep_on_deep(current, a_new))
+ if (initng_depend_deep(a_new, current)
+ && initng_depend_deep(current, a_new))
{
F_("load_to_active(%s): not loading service %s, because it has a circular dependency on %s\n", service_name, a_new->name, current->name);
initng_active_db_free(a_new);
@@ -270,7 +271,7 @@
continue;
/* if current depends on service failed to start */
- if (initng_active_db_dep_on(current, service) == TRUE)
+ if (initng_depend(current, service) == TRUE)
initng_common_mark_service(current, &START_DEP_FAILED);
}
}
Modified: initng/src/initng_control_command.c
==============================================================================
--- initng/src/initng_control_command.c (original)
+++ initng/src/initng_control_command.c Mon Feb 6 13:01:06 2006
@@ -144,4 +144,4 @@
else
(*cmd->u.void_command_void_call)();
return(TRUE);
-}
\ No newline at end of file
+}
Modified: initng/src/initng_depend.c
==============================================================================
--- initng/src/initng_depend.c (original)
+++ initng/src/initng_depend.c Mon Feb 6 13:01:06 2006
@@ -39,7 +39,7 @@
/*
- * active_db_dep_on:
+ * initng_depend:
* Will check with all plugins and return TRUE
* if service depends on check.
*/
@@ -63,17 +63,17 @@
while_list_safe(current, &g.DEP_ON, s)
{
if ((result = (*current->c.dep_on_check) (service, check) == TRUE))
- break;
+ return(TRUE);
}
- return result;
+ return(FALSE);
}
/*
* A deeper deepfind.
* Logic, we wanna make sure that depend check in a deeper level.
* if daemon/smbd -> daemon/samba -> system/checkroot -> system/initial.
- * So should active_db_dep_on_deep(daemon/smbd, system/initial) == TRUE
+ * So should initng_depend_deep(daemon/smbd, system/initial) == TRUE
*
* Sumary, does service depends on check?
*/
@@ -109,7 +109,7 @@
* current may depend (deep) on check */
while_active_db(current)
{
- if (initng_active_db_dep_on(service, current))
+ if (initng_depend(service, current))
{
if ((result = initng_depend_deep2(current, check, stack)))
break;
Modified: initng/src/initng_handler.c
==============================================================================
--- initng/src/initng_handler.c (original)
+++ initng/src/initng_handler.c Mon Feb 6 13:01:06 2006
@@ -41,6 +41,7 @@
#include "initng_execute.h"
#include "initng_common.h"
#include "initng_load_module.h"
+#include "initng_depend.h"
#include "initng_handler.h"
#include "initng_kill_handler.h"
@@ -197,6 +198,8 @@
W_("Unable to mark service %s START_MARK!\n", service_to_start->name);
return(FALSE);
}
+
+ initng_depend_start_deps(service_to_start);
if (service_to_start->type->start_service)
return ((*service_to_start->type->start_service) (service_to_start));
Modified: initng/src/initng_static_process_types.c
==============================================================================
--- initng/src/initng_static_process_types.c (original)
+++ initng/src/initng_static_process_types.c Mon Feb 6 13:01:06 2006
@@ -41,24 +41,17 @@
static void handle_killed_daemon(active_db_h * killed_service,
process_h * process);
-static void handle_killed_start(active_db_h * killed_service,
- process_h * process);
-static void handle_killed_stop(active_db_h * killed_service,
- process_h * process);
-/*ptype_h T_START = { "start", &handle_killed_start };
- ptype_h T_STOP = { "stop", &handle_killed_stop };*/
ptype_h T_DAEMON = { "daemon", &handle_killed_daemon };
ptype_h T_KILL = { "kill", NULL };
void initng_static_process_types_add_default(void)
{
-/* initng_process_db_ptype_add(&T_START);
- initng_process_db_ptype_add(&T_STOP);*/
initng_process_db_ptype_add(&T_DAEMON);
initng_process_db_ptype_add(&T_KILL);
}
+
static void handle_killed_daemon(active_db_h * service, process_h * process)
{
assert(service);
@@ -97,100 +90,3 @@
initng_common_mark_service(service, &STOPPED);
}
-#ifdef NONO
-/*
- * handle_killed_start(), description:
- *
- * A process dies, and kill_handler walks the active_db looking for a match
- * on that pid, if it founds a match for a active->start_process, this
- * function is called, with a pointer to that active_service to
- * handle the situation.
- */
-static void handle_killed_start(active_db_h * service, process_h * process)
-{
- assert(service);
- assert(service->name);
- assert(service->current_state);
- assert(service->current_state->state_name);
- assert(process);
-
- D_("handle_killed_start(%s): initial status: \"%s\".\n",
- service->name, service->current_state->state_name);
-
- /* Set the universal variable, that signalize that something happend */
- initng_global_set_interrupt();
-
- /*
- * If the return code (for example "exit 1", in a bash script)
- * from the program, is bigger than 0, this commonly signalize
- * that something got wrong, print this as an error msg on screen
- */
- if (process->r_code > 0)
- F_(" start %s, Returned with exit %i.\n", service->name,
- process->r_code);
-
- /*
- * If service is stopping, ignore this signal
- */
- if (service->current_state != &STARTING)
- {
- F_("Start exited!, and service is not marked starting!\n");
- return;
- }
-
-
- /*
- * Make sure r_code don't signal error (can be override by UP_ON_FAILURE.
- */
- if (process->r_code && !initng_active_db_is(&UP_ON_FAILURE, service))
- {
-
- initng_common_mark_service(service, &FAIL_STARTING);
- list_del(&process->list);
- initng_process_db_free(process);
- return;
- }
-
- /* OK! now service is DONE! */
- initng_common_mark_service(service, &DONE);
-
- /* free the process struct, to spare memory */
- list_del(&process->list);
- initng_process_db_free(process);
-}
-
-
-/* to do when a stop action dies */
-static void handle_killed_stop(active_db_h * service, process_h * process)
-{
- assert(service);
- assert(service->name);
- assert(service->current_state);
- assert(service->current_state->state_name);
- assert(process);
-
- D_("(%s);\n", service->name);
-
- if (service->current_state != &STOPPING)
- {
- F_("stop service died, but service is not status STOPPING!\n");
- }
-
- /*
- * If the return code (for example "exit 1", in a bash script)
- * from the program, is bigger than 0, this commonly signalize
- * that something got wrong, print this as an error msg on screen
- */
- if (process->r_code > 0)
- F_(" stop %s, Returned with exit %i.\n", service->name,
- process->r_code);
-
-
- /* free stopped process data */
- list_del(&process->list);
- initng_process_db_free(process);
-
- /* mark service stopped */
- initng_common_mark_service(service, &STOPPED);
-}
-#endif
Modified: initng/src/initng_static_service_types.c
==============================================================================
--- initng/src/initng_static_service_types.c (original)
+++ initng/src/initng_static_service_types.c Mon Feb 6 13:01:06 2006
@@ -41,6 +41,7 @@
#include "initng_main.h"
#include "initng_execute.h"
#include "initng_common.h"
+#include "initng_depend.h"
#include "initng_load_module.h"
#include "initng_handler.h"
#include "initng_kill_handler.h"
@@ -108,7 +109,7 @@
continue;
/* if current depends on the one we are stopping */
- if (initng_active_db_dep_on(current, service_to_stop) == TRUE)
+ if (initng_depend(current, service_to_stop) == TRUE)
initng_handler_stop_service(current);
}
Modified: initng/src/initng_static_states.c
==============================================================================
--- initng/src/initng_static_states.c (original)
+++ initng/src/initng_static_states.c Mon Feb 6 13:01:06 2006
@@ -143,7 +143,7 @@
continue;
/* if current is not one that it depends on continue */
- if (initng_active_db_dep_on(service_to_start, current) == FALSE)
+ if (initng_depend(service_to_start, current) == FALSE)
continue;
/* if servuce dep on is starting, wait a bit */
@@ -206,26 +206,6 @@
initng_common_mark_service(service_to_start, &RUNNING);
}
-static void handle_START_DEP_MET_service(active_db_h * service_to_start)
-{
-#ifdef NONO
- if (!initng_common_mark_service(service_to_start, &STARTING))
- return;
-
- /* F I N A L L Y S T A R T */
-
- switch (initng_execute_launch(service_to_start, &T_START))
- {
- case FALSE:
- case FAIL:
- F_("Service %s, could not launch start, did not find any to launch!\n", service_to_start->name);
- initng_common_mark_service(service_to_start, &FAIL_STARTING);
- return; /* return with status */
- default:
- return;
- }
-#endif
-}
static void handle_START_DEP_MET(active_db_h * service_to_start)
{
@@ -280,7 +260,7 @@
continue;
/* Does service_to_stop depends on current ?? */
- if (initng_active_db_dep_on(current, service_to_stop) == FALSE)
+ if (initng_depend(current, service_to_stop) == FALSE)
continue;
/* if its done, this is pefrect */
@@ -329,43 +309,6 @@
-/*
- * Handles:
- * STOP_DEP_MET ----->> STOPPING
- */
-
-static void handle_STOP_DEP_MET_service(active_db_h * service_to_stop)
-{
-#ifdef NONO
- /* mark this service as STOPPING */
- initng_common_mark_service(service_to_stop, &STOPPING);
-
- /* launch stop service */
- switch (initng_execute_launch(service_to_stop, &T_STOP))
- {
- case FAIL:
- F_(" -- (%s): fail launch stop!\n", service_to_stop->name);
- initng_common_mark_service(service_to_stop, &FAIL_STOPPING);
- return;
- case FALSE:
- /* there exists no stop process */
- initng_common_mark_service(service_to_stop, &STOPPED);
- return;
- default:
- /* the alarm makes sure this will be killed if it takes to long. */
- if (initng_active_db_is(&STOP_TIMEOUT, service_to_stop))
- {
- initng_global_set_sleep(initng_active_db_get_int
- (&STOP_TIMEOUT, service_to_stop) + 1);
- }
- else
- {
- initng_global_set_sleep(SECONDS_BEFORE_KILL + 1);
- }
- return;
- }
-#endif
-}
static void handle_STOP_DEP_MET_daemon(active_db_h * service_to_stop)
{
@@ -536,7 +479,7 @@
continue;
/* check that current needs service_stopped */
- if (initng_active_db_dep_on(current, service_stopped) == FALSE)
+ if (initng_depend(current, service_stopped) == FALSE)
continue;
/* dont stop a stopped service */
More information about the Initng-svn
mailing list