[Initng-svn] r2995 - in initng: plugins plugins/critical
plugins/daemon plugins/fstat plugins/idleprobe plugins/syncron src
svn at initng.thinktux.net
svn at initng.thinktux.net
Tue Feb 14 11:27:36 CET 2006
Author: jimmy
Date: Tue Feb 14 11:27:35 2006
New Revision: 2995
Modified:
initng/plugins/Makefile.am
initng/plugins/critical/initng_critical.c
initng/plugins/daemon/initng_daemon.c
initng/plugins/fstat/initng_fstat.c
initng/plugins/idleprobe/initng_idleprobe.c
initng/plugins/syncron/initng_syncron.c
initng/src/initng_active_db.c
initng/src/initng_common.c
initng/src/initng_static_states.c
initng/src/initng_static_states.h
Log:
Now finally removed all unused static states.
Also clean up all plugins.
Modified: initng/plugins/Makefile.am
==============================================================================
--- initng/plugins/Makefile.am (original)
+++ initng/plugins/Makefile.am Tue Feb 14 11:27:35 2006
@@ -25,9 +25,9 @@
SUBDIRS+=cpout
endif
-if BUILD_CRON
- SUBDIRS+=cron
-endif
+#if BUILD_CRON
+# SUBDIRS+=cron
+#endif
if BUILD_CRITICAL
SUBDIRS+=critical
Modified: initng/plugins/critical/initng_critical.c
==============================================================================
--- initng/plugins/critical/initng_critical.c (original)
+++ initng/plugins/critical/initng_critical.c Tue Feb 14 11:27:35 2006
@@ -41,15 +41,13 @@
};
/* returns TRUE if all use deps are started */
-static int check_critical(active_db_h * service, a_state_h * status)
+static int check_critical(active_db_h * service)
{
assert(service);
assert(service->name);
- /* if critical is set */
- if (!initng_active_db_is(&CRITICAL, service))
- return (TRUE);
-
+ if(!IS_FAILED(service))
+ return(TRUE);
F_("Service %s failed, this is critical, going su_login!!\n",
service->name);
@@ -63,8 +61,12 @@
initng_service_cache_free(service->from_service);
service->from_service = NULL;
}
- initng_common_get_service(service);
- initng_common_mark_service(service, &WAITING_FOR_START_DEP);
+
+ /* Reset the service state */
+ initng_common_mark_service(service, &NEW);
+
+ /* start the service again */
+ initng_handler_start_service(service);
/* Make sure full runlevel starting fine */
if (!initng_active_db_find_by_exact_name(g.runlevel))
@@ -84,7 +86,7 @@
}
initng_service_data_types_add(&CRITICAL);
- initng_active_state_add_test(&FAIL_STARTING, 80, &check_critical);
+ initng_plugin_hook_add(&g.IS_CHANGE, 80, &check_critical);
return (TRUE);
}
@@ -92,5 +94,5 @@
{
D_("module_unload();\n");
initng_service_data_types_del(&CRITICAL);
- initng_active_state_del_test(&FAIL_STARTING, &check_critical);
+ initng_plugin_hook_del(&g.IS_CHANGE, &check_critical);
}
Modified: initng/plugins/daemon/initng_daemon.c
==============================================================================
--- initng/plugins/daemon/initng_daemon.c (original)
+++ initng/plugins/daemon/initng_daemon.c Tue Feb 14 11:27:35 2006
@@ -624,7 +624,7 @@
if (timeout > 0 && timeout < time(0))
{
F_("Service \"%s\" wait for pidfile timed out!\n", s->name);
- initng_common_mark_service(s, &FAIL_STARTING);
+ initng_common_mark_service(s, &DAEMON_FAIL_STARTING);
return;
}
@@ -640,7 +640,7 @@
if (!p)
{
F_("Did not find a daemon process on this service!\n");
- initng_common_mark_service(s, &FAIL_STARTING);
+ initng_common_mark_service(s, &DAEMON_FAIL_STARTING);
return;
}
@@ -670,7 +670,7 @@
if (kill(pid, 0) < 0 && (errno == ESRCH))
{
F_("Got a non-existent pid %i for daemon \"%s\"\n", pid, s->name);
- initng_common_mark_service(s, &FAIL_STARTING);
+ initng_common_mark_service(s, &DAEMON_FAIL_STARTING);
return;
}
@@ -687,7 +687,7 @@
initng_active_db_unset(&INTERNAL_PIDFILE_TIMEOUT, s);
/* mark this service running */
- initng_common_mark_service(s, &RUNNING);
+ initng_common_mark_service(s, &DAEMON_RUNNING);
}
/*
Modified: initng/plugins/fstat/initng_fstat.c
==============================================================================
--- initng/plugins/fstat/initng_fstat.c (original)
+++ initng/plugins/fstat/initng_fstat.c Tue Feb 14 11:27:35 2006
@@ -47,7 +47,7 @@
/*
* Do this check before START_DEP_MET can be set.
*/
-static int check_files_to_exist(active_db_h * service, a_state_h * status)
+static int check_files_to_exist(active_db_h * service)
{
const char *file = NULL;
struct stat file_stat;
@@ -72,8 +72,7 @@
/*
* Do this test before status RUNNING can be set.
*/
-static int check_files_to_exist_after(active_db_h * service,
- a_state_h * status)
+static int check_files_to_exist_after(active_db_h * service)
{
const char *file = NULL;
struct stat file_stat;
@@ -109,8 +108,8 @@
initng_service_data_types_add(&FILES_TO_EXIST);
initng_service_data_types_add(&FILES_TO_EXIST_AFTER);
- initng_active_state_add_test(&START_DEP_MET, 55, &check_files_to_exist);
- initng_active_state_add_test(&RUNNING, 55, &check_files_to_exist_after);
+ initng_plugin_hook_add(&g.START_DEP_MET, 55, &check_files_to_exist);
+ initng_plugin_hook_add(&g.UP_MET, 55, &check_files_to_exist_after);
return (TRUE);
}
@@ -119,6 +118,6 @@
S_;
initng_service_data_types_del(&FILES_TO_EXIST);
initng_service_data_types_del(&FILES_TO_EXIST_AFTER);
- initng_active_state_del_test(&START_DEP_MET, &check_files_to_exist);
- initng_active_state_del_test(&RUNNING, &check_files_to_exist_after);
+ initng_plugin_hook_del(&g.START_DEP_MET, &check_files_to_exist);
+ initng_plugin_hook_del(&g.UP_MET, &check_files_to_exist_after);
}
Modified: initng/plugins/idleprobe/initng_idleprobe.c
==============================================================================
--- initng/plugins/idleprobe/initng_idleprobe.c (original)
+++ initng/plugins/idleprobe/initng_idleprobe.c Tue Feb 14 11:27:35 2006
@@ -187,7 +187,7 @@
return (FALSE);
}
-static int check_cpu_idle(active_db_h * service, a_state_h * status)
+static int check_cpu_idle(active_db_h * service)
{
S_;
int value = 0;
@@ -218,7 +218,7 @@
initng_service_data_types_add(&WAIT_FOR_CPU_IDLE);
initng_service_data_types_add(&WAIT_FOR_CPU_COUNT);
- initng_active_state_add_test(&START_DEP_MET, 90, &check_cpu_idle);
+ initng_plugin_hook_add(&g.START_DEP_MET, 90, &check_cpu_idle);
return (TRUE);
}
@@ -227,7 +227,7 @@
S_;
initng_service_data_types_del(&WAIT_FOR_CPU_IDLE);
initng_service_data_types_del(&WAIT_FOR_CPU_COUNT);
- initng_active_state_del_test(&START_DEP_MET, &check_cpu_idle);
+ initng_plugin_hook_del(&g.START_DEP_MET, &check_cpu_idle);
if (fp_proc)
fclose(fp_proc);
Modified: initng/plugins/syncron/initng_syncron.c
==============================================================================
--- initng/plugins/syncron/initng_syncron.c (original)
+++ initng/plugins/syncron/initng_syncron.c Tue Feb 14 11:27:35 2006
@@ -36,12 +36,24 @@
s_entry SYNCRON = { "syncron", STRING, NULL,
"All services with this same syncron string, can't be started asynchronous."
};
-
+a_state_h *SERVICE_START_RUN;
static int check;
+static int resolv_SSR(void)
+{
+ SERVICE_START_RUN=initng_active_state_find("SERVICE_START_RUN");
+ if(!SERVICE_START_RUN)
+ {
+ F_("Coud not resolv SERVICE_START_RUN, are service type loaded?");
+ return(FALSE);
+
+ }
+ return(TRUE);
+}
+
+
/* Make sure if service syncron=module_loading, only one of the services with module_loading runs at once */
-static int check_syncronicly_service(active_db_h * service,
- a_state_h * status)
+static int check_syncronicly_service(active_db_h * service)
{
active_db_h *current, *q = NULL;
const char *service_syncron;
@@ -49,6 +61,10 @@
assert(service);
assert(service->name);
+
+ /* we must have this state resolve, to compare it */
+ if(!resolv_SSR())
+ return(TRUE);
if ((service_syncron =
initng_active_db_get_string(&SYNCRON, service)) == NULL)
@@ -61,8 +77,9 @@
{
continue;
}
- /* Check every other service in STARTING, see if it has SYNCRON = same_as_us */
- if (IS_MARK(current, &STARTING))
+
+ /* If this service has the start process running */
+ if (IS_MARK(current, SERVICE_START_RUN))
{
if ((current_syncron =
initng_active_db_get_string(&SYNCRON, current)) != NULL)
@@ -81,17 +98,20 @@
}
/* Make sure there is only one service starting */
-static int check_syncronicly(active_db_h * service, a_state_h * status)
+static int check_syncronicly(active_db_h * service)
{
active_db_h *current, *q = NULL;
+ /* we must have this state resolve, to compare it */
+ if(!resolv_SSR())
+ return(TRUE);
while_active_db_safe(current, q)
{
/* don't check ourself */
if (current == service)
continue;
- if (current->current_state == &START_DEP_MET
- || current->current_state == &STARTING)
+
+ if (IS_MARK(service, SERVICE_START_RUN))
{
/* no i cant set this status yet */
return (FALSE);
@@ -104,6 +124,7 @@
int module_init(const char *version)
{
int i;
+ SERVICE_START_RUN=NULL;
D_("module_init();\n");
if (strcmp(version, INITNG_VERSION) != 0)
@@ -116,15 +137,14 @@
if (strstr(g.Argv[i], "synchronously"))
{
check = TRUE;
- initng_active_state_add_test(&START_DEP_MET, 10,
- &check_syncronicly);
+ initng_plugin_hook_add(&g.START_DEP_MET, 10, &check_syncronicly);
+
return (TRUE);
}
check = FALSE;
/* Notice this is only added if we don't have --synchronously */
D_("Adding synchron\n");
- initng_active_state_add_test(&START_DEP_MET, 10,
- &check_syncronicly_service);
+ initng_plugin_hook_add(&g.START_DEP_MET, 10, &check_syncronicly_service);
return (TRUE);
@@ -133,7 +153,8 @@
void module_unload(void)
{
- initng_active_state_del_test(&START_DEP_MET, &check_syncronicly);
- initng_active_state_del_test(&START_DEP_MET, &check_syncronicly_service);
+ if(check==TRUE)
+ initng_plugin_hook_del(&g.START_DEP_MET, &check_syncronicly);
+ initng_plugin_hook_del(&g.START_DEP_MET, &check_syncronicly_service);
initng_service_data_types_del(&SYNCRON);
}
Modified: initng/src/initng_active_db.c
==============================================================================
--- initng/src/initng_active_db.c (original)
+++ initng/src/initng_active_db.c Tue Feb 14 11:27:35 2006
@@ -262,7 +262,7 @@
sizeof(struct timeval));
/* mark this service as stopped, because it is not yet starting, or running */
- new_active->current_state = &STOPPED;
+ new_active->current_state = &NEW;
new_active->from_service = NULL;
/* return the newly created active_db_h */
Modified: initng/src/initng_common.c
==============================================================================
--- initng/src/initng_common.c (original)
+++ initng/src/initng_common.c Tue Feb 14 11:27:35 2006
@@ -262,6 +262,8 @@
*/
static void dep_failed_to_start(active_db_h * service)
{
+ /* TODO, find a way to handle this */
+#ifdef NONO
active_db_h *current = NULL;
/* walk over all services */
@@ -274,6 +276,7 @@
if (initng_depend(current, service) == TRUE)
initng_common_mark_service(current, &START_DEP_FAILED);
}
+#endif
}
#ifdef DEP_FAILED_TO_STOP
Modified: initng/src/initng_static_states.c
==============================================================================
--- initng/src/initng_static_states.c (original)
+++ initng/src/initng_static_states.c Tue Feb 14 11:27:35 2006
@@ -51,14 +51,6 @@
#include "initng_static_process_types.h"
#include "initng_static_service_types.h"
-/* function defines */
-static void handle_WAITING_FOR_START_DEP(active_db_h * service_to_start);
-static void handle_START_DEP_MET(active_db_h * service_to_start);
-static void handle_WAITING_FOR_STOP_DEP(active_db_h * service_to_stop);
-static void handle_STOP_DEP_MET(active_db_h * service_to_stop);
-static void handle_STOPPED(active_db_h * service_to_stop);
-static void handle_STOP_MARKED(active_db_h * service);
-
/*
* a_state_h
@@ -68,248 +60,13 @@
* void state_interrupt
*/
-a_state_h STOPPED = { "STOPPED", IS_DOWN, &handle_STOPPED };
+a_state_h NEW = { "NEW", IS_DOWN, NULL };
a_state_h LOADING = { "LOADING", IS_DOWN, NULL };
-a_state_h START_MARK = { "START_MARK", IS_STARTING, NULL };
-a_state_h STARTING = { "STARTING", IS_STARTING, NULL };
-a_state_h WAITING_FOR_START_DEP = { "WAITING_FOR_START_DEP", IS_STARTING,
- &handle_WAITING_FOR_START_DEP
-};
-a_state_h START_DEP_MET = { "START_DEP_MET", IS_STARTING, &handle_START_DEP_MET };
-a_state_h FAIL_STARTING = { "FAIL_STARTING", IS_FAILED, NULL };
-a_state_h DAEMON_EXIT_BAD = { "DAEMON_EXIT_BAD", IS_FAILED, NULL };
-a_state_h START_DEP_FAILED = { "START_DEP_FAILED", IS_FAILED, NULL };
-a_state_h RUNNING = { "RUNNING", IS_UP, NULL };
-a_state_h DONE = { "DONE", IS_UP, NULL };
-a_state_h STOPPING = { "STOPPING", IS_STOPPING, NULL };
-a_state_h WAITING_FOR_STOP_DEP = { "WAITING_FOR_STOP_DEP", IS_STOPPING,
- &handle_WAITING_FOR_STOP_DEP
-};
-a_state_h STOP_DEP_MET = { "STOP_DEP_MET", IS_STOPPING, &handle_STOP_DEP_MET
-};
-a_state_h STOP_DEP_FAILED = { "STOP_DEP_FAILED", IS_FAILED, NULL };
-a_state_h FAIL_STOPPING = { "FAIL_STOPPING", IS_FAILED, NULL };
-a_state_h STOP_MARKED = { "STOP_MARKED", IS_STOPPING, handle_STOP_MARKED };
a_state_h FREEING = { "FREEING", IS_DOWN, NULL };
-/*a_state_h WAIT_FOR_CRON = { "WAIT_FOR_CRON", IS_WAITING, NULL };*/
void initng_static_states_add_default(void)
{
initng_active_state_add(&LOADING);
- initng_active_state_add(&STARTING);
- initng_active_state_add(&WAITING_FOR_START_DEP);
- initng_active_state_add(&START_DEP_MET);
- initng_active_state_add(&FAIL_STARTING);
- initng_active_state_add(&START_DEP_FAILED);
- initng_active_state_add(&RUNNING);
- initng_active_state_add(&DONE);
- initng_active_state_add(&STOPPING);
- initng_active_state_add(&WAITING_FOR_STOP_DEP);
- initng_active_state_add(&STOP_DEP_MET);
- initng_active_state_add(&STOP_DEP_FAILED);
- initng_active_state_add(&FAIL_STOPPING);
- initng_active_state_add(&STOPPED);
- initng_active_state_add(&STOP_MARKED);
initng_active_state_add(&FREEING);
- /*initng_active_state_add(&WAIT_FOR_CRON);*/
- initng_active_state_add(&DAEMON_EXIT_BAD);
-}
-
-
-
- /* D O S T U F F */
-
-static void handle_STOP_MARKED(active_db_h * service)
-{
- initng_common_mark_service(service, &WAITING_FOR_STOP_DEP);
-}
-
-
-/* This is the function that really launches the start-marked services if all deps are up */
-static void handle_WAITING_FOR_START_DEP(active_db_h * service_to_start)
-{
- active_db_h *current = NULL;
-
- assert(service_to_start);
-
- /*
- * Check so all deps, that needs service_to_start, is up.
- */
- while_active_db(current)
- {
- if (current == service_to_start)
- continue;
-
- /* if current is not one that it depends on continue */
- if (initng_depend(service_to_start, 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 START_DEP_FAILED */
- if (!IS_UP(current))
- {
- D_("service %s depending on service %s status %s, aborting.\n",
- service_to_start->name, current->name,
- current->current_state->state_name);
- initng_common_mark_service(service_to_start, &START_DEP_FAILED);
- return;
- }
- }
-
- /* check with start dep med dependencies */
- if(initng_depend_start_dep_met(service_to_start)!=TRUE)
- {
- D_("Some plugin say that the start dependencies for this service is not met.\n");
- return;
- }
-
- if (g.sys_state == STATE_STOPPING)
- {
- initng_common_mark_service(service_to_start, &STOPPED);
- return;
- }
-
- if (g.sys_state != STATE_STARTING && g.sys_state != STATE_UP)
- {
- F_("Can't start service, when system status is: %i !\n", g.sys_state);
- return;
- }
-
- /* set status to START_DEP_MET */
- initng_common_mark_service(service_to_start, &START_DEP_MET);
-}
-
-
-static void handle_START_DEP_MET(active_db_h * service_to_start)
-{
- assert(service_to_start);
-
- if (g.sys_state == STATE_STOPPING)
- {
- initng_common_mark_service(service_to_start, &STOPPED);
- return;
- }
-
- F_("DEP MET BUT CANT HANDLE!\n");
- initng_common_mark_service(service_to_start, &FAIL_STARTING);
-}
-
-
-/*
- * This function is called on interrupt for all services with
- * active status WAITING_FOR_STOP_DEP.
- */
-static void handle_WAITING_FOR_STOP_DEP(active_db_h * service_to_stop)
-{
- active_db_h *current = NULL;
-
- assert(service_to_stop);
- D_("handle_WAITING_FOR_STOP_DEP (%s)!\n", service_to_stop->name);
- /*
- * Check so all deps, that needs service_to_stop, is down.
- * if there are services depending on this one still running, return false and still try
- */
- while_active_db(current)
- {
- if (current == service_to_stop)
- continue;
-
- /* Does service_to_stop depends on current ?? */
- if (initng_depend(current, service_to_stop) == 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 stop dep med dependencies */
- if(initng_depend_stop_dep_met(service_to_stop)!=TRUE)
- {
- D_("Some plugin say that the start dependencies for this service is not met.\n");
- return;
- }
-
-
-
- /* ok, stopping deps are met */
- D_("Try set STOP_DEP_MET!\n");
- initng_common_mark_service(service_to_stop, &STOP_DEP_MET);
-}
-
-
-
-
-
-
-
-static void handle_STOP_DEP_MET(active_db_h * service_to_stop)
-{
-
-
- initng_common_mark_service(service_to_stop, &FAIL_STOPPING);
- F_("DON'T KNOW HOW TO STOP %s!\n", service_to_stop->name);
-}
-
-static void handle_STOPPED(active_db_h * service_stopped)
-{
- active_db_h *current, *safe = NULL;
-
- /*
- * Make sure there is no services that needs this
- * that still think its running.
- */
- while_active_db_safe(current, safe)
- {
- /* no idea to stop myself */
- if (current == service_stopped)
- continue;
-
- /* check that current needs service_stopped */
- if (initng_depend(current, service_stopped) == FALSE)
- continue;
-
- /* don't stop a stopped service */
- if (IS_DOWN(current))
- continue;
-
- /* if stop this */
- D_("%s have to stop %s.\n", service_stopped->name, current->name);
- initng_handler_stop_service(current);
- }
-
- /* check if this service is restarting */
- if (initng_active_db_is(&RESTARTING, service_stopped))
- {
- initng_active_db_remove(&RESTARTING, service_stopped);
- initng_handler_start_service(service_stopped);
- D_("Service is restarting now!\n");
- return;
- }
-
-
- /* free service, and forget */
- initng_active_db_del(service_stopped);
- initng_active_db_free(service_stopped);
- D_("Service removed.\n");
}
Modified: initng/src/initng_static_states.h
==============================================================================
--- initng/src/initng_static_states.h (original)
+++ initng/src/initng_static_states.h Tue Feb 14 11:27:35 2006
@@ -21,25 +21,9 @@
#ifndef INITNG_STATIC_STATES
#define INITNG_STATIC_STATES
-extern a_state_h STOPPED;
+extern a_state_h NEW;
extern a_state_h LOADING;
-extern a_state_h START_MARK;
-extern a_state_h STARTING;
-extern a_state_h WAITING_FOR_START_DEP;
-extern a_state_h START_DEP_MET;
-extern a_state_h FAIL_STARTING;
-extern a_state_h START_DEP_FAILED;
-extern a_state_h RUNNING;
-extern a_state_h DONE;
-extern a_state_h STOPPING;
-extern a_state_h WAITING_FOR_STOP_DEP;
-extern a_state_h STOP_DEP_MET;
-extern a_state_h STOP_DEP_FAILED;
-extern a_state_h FAIL_STOPPING;
-extern a_state_h STOP_MARKED;
extern a_state_h FREEING;
-/*extern a_state_h WAIT_FOR_CRON;*/
-extern a_state_h DAEMON_EXIT_BAD;
void initng_static_states_add_default(void);
#endif
More information about the Initng-svn
mailing list