[Initng-svn] r3173 - initng/trunk/plugins/service

svn at initng.thinktux.net svn at initng.thinktux.net
Thu Mar 2 12:22:25 CET 2006


Author: jimmy
Date: Thu Mar  2 12:22:25 2006
New Revision: 3173

Modified:
   initng/trunk/plugins/service/initng_service.c
Log:
Really fail the service, if start_timeout or stop_timeout is reached.



Modified: initng/trunk/plugins/service/initng_service.c
==============================================================================
--- initng/trunk/plugins/service/initng_service.c	(original)
+++ initng/trunk/plugins/service/initng_service.c	Thu Mar  2 12:22:25 2006
@@ -201,6 +201,10 @@
     { "SERVICE_FAIL_STARTING", IS_FAILED, NULL, NULL, NULL };
 a_state_h SERVICE_FAIL_STOPPING =
     { "SERVICE_FAIL_STOPPING", IS_FAILED, NULL, NULL, NULL };
+a_state_h SERVICE_START_FAILED_TIMEOUT =
+    { "SERVICE_START_FAILED_TIMEOUT", IS_FAILED, NULL, NULL, NULL };
+a_state_h SERVICE_STOP_FAILED_TIMEOUT =
+    { "SERVICE_STOP_FAILED_TIMEOUT", IS_FAILED, NULL, NULL, NULL };
 
 
 /*
@@ -292,6 +296,8 @@
     initng_active_state_add(&SERVICE_STOP_DEPS_FAILED);
     initng_active_state_add(&SERVICE_FAIL_STARTING);
     initng_active_state_add(&SERVICE_FAIL_STOPPING);
+    initng_active_state_add(&SERVICE_START_FAILED_TIMEOUT);
+    initng_active_state_add(&SERVICE_STOP_FAILED_TIMEOUT);
 
     initng_service_data_types_add(&START_TIMEOUT);
     initng_service_data_types_add(&STOP_TIMEOUT);
@@ -324,6 +330,8 @@
     initng_active_state_del(&SERVICE_STOP_DEPS_FAILED);
     initng_active_state_del(&SERVICE_FAIL_STARTING);
     initng_active_state_del(&SERVICE_FAIL_STOPPING);
+    initng_active_state_del(&SERVICE_START_FAILED_TIMEOUT);
+    initng_active_state_del(&SERVICE_STOP_FAILED_TIMEOUT);
 
     initng_service_data_types_del(&START_TIMEOUT);
     initng_service_data_types_del(&STOP_TIMEOUT);
@@ -524,6 +532,9 @@
 
     /* send the process the SIGKILL signal */
     kill(process->pid, SIGKILL);
+
+    /* set service state, to a failure state */
+    initng_common_mark_service(service, &SERVICE_START_FAILED_TIMEOUT);
 }
 
 static void timeout_SERVICE_STOP_RUN(active_db_h * service)
@@ -550,6 +561,9 @@
 
     /* send the process the SIGKILL signal */
     kill(process->pid, SIGKILL);
+    
+    /* set service state, to a failure state */
+    initng_common_mark_service(service, &SERVICE_STOP_FAILED_TIMEOUT);
 }
 
 
@@ -593,9 +607,19 @@
            process->r_code);
 
     /*
+     * If this exited after a timeout, stay failed
+     */
+    if(IS_MARK(service, &SERVICE_START_FAILED_TIMEOUT))
+    {
+        list_del(&process->list);
+        initng_process_db_free(process);
+        return;
+    }	
+
+    /*
      * If service is stopping, ignore this signal
      */
-    if (service->current_state != &SERVICE_START_RUN)
+    if (!IS_MARK(service, &SERVICE_START_RUN))
     {
         F_("Start exited!, and service is not marked starting!\n");
         return;
@@ -636,7 +660,18 @@
 
     D_("(%s);\n", service->name);
 
-    if (service->current_state != &SERVICE_STOP_RUN)
+    /*
+     * If this exited after a timeout, stay failed
+     */
+    if(IS_MARK(service, &SERVICE_STOP_FAILED_TIMEOUT))
+    {
+        list_del(&process->list);
+        initng_process_db_free(process);
+        return;
+    }	
+
+    /* make sure its a STOP_RUN state */
+    if (!IS_MARK(service, &SERVICE_STOP_RUN))
     {
         F_("stop service died, but service is not status STOPPING!\n");
         return;


More information about the Initng-svn mailing list