[Initng-svn] r2983 - initng/src

svn at initng.thinktux.net svn at initng.thinktux.net
Fri Feb 10 12:21:26 CET 2006


Author: jimmy
Date: Fri Feb 10 12:21:26 2006
New Revision: 2983

Modified:
   initng/src/initng_handler.c
Log:
Some cleaning in src/initng_handler.c


Modified: initng/src/initng_handler.c
==============================================================================
--- initng/src/initng_handler.c	(original)
+++ initng/src/initng_handler.c	Fri Feb 10 12:21:26 2006
@@ -153,7 +153,7 @@
     assert(service_to_start->name);
     assert(service_to_start->current_state);
 
-    S_;
+    D_("start_service(%s);\n", service_to_start->name);
 
     if (!service_to_start->type)
     {
@@ -170,12 +170,25 @@
     }
 
     /* it might already be starting */
-    if (!IS_MARK(service_to_start, &LOADING)
-        && (IS_STARTING(service_to_start) || IS_WAITING(service_to_start)))
+    if (IS_STARTING(service_to_start) || IS_WAITING(service_to_start))
     {
         D_("service %s is starting already.\n", service_to_start->name);
         return (TRUE);
     }
+    
+    /* if it failed */
+    if (IS_FAILED(service_to_start))
+    {
+	F_("Service %s is failed, and must be reset before can be tried to start again!\n", service_to_start->name);
+	return (FALSE);
+    }
+    
+    /* IF service is stopping, we can not currently start it */
+    if (IS_STOPPING(service_to_start))
+    {
+        D_("service %s is stopping, cant start it.\n", service_to_start->name);
+        return (TRUE);
+    }
 
     /* it might already be up */
     if (IS_UP(service_to_start))
@@ -192,19 +205,19 @@
         return (FALSE);
     }
     
-    /* START_MARK service */
-    /*if(!initng_common_mark_service(service_to_start, &START_MARK))
+    /* This will run this functuin (start_service) for all dependecys this service have. */
+    if (initng_depend_start_deps(service_to_start)!=TRUE)
     {
-	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));
+	F_("Coud not start %s, becouse a required dependency coud not be found.\n");
+	return (FALSE);
+    }
 
-    return (FALSE);
+    /* Now execute the local start_service code, in the service type plugin. */
+    if (!service_to_start->type->start_service)
+	return (FALSE);
+	
+    /* execute it */	
+    return ((*service_to_start->type->start_service) (service_to_start));
 }
 
     /* S T O P     S E R V I C E */
@@ -212,7 +225,9 @@
 {
 
     assert(service_to_stop);
+    assert(service_to_stop->name);
     assert(service_to_stop->current_state);
+    
     D_("stop_service(%s);\n", service_to_stop->name);
 
     if (!service_to_stop->type)
@@ -221,6 +236,7 @@
         return (FALSE);
     }
 
+    /* check so it not failed */
     if (IS_FAILED(service_to_stop))
     {
         D_("Service %s is set filed, and cant be stopped.\n",
@@ -236,32 +252,38 @@
     }
 
     /* if starting, direct abort */
-
     if (IS_STARTING(service_to_stop))
     {
         D_("Service %s is starting, can't stop it!\n", service_to_stop->name);
-        /*mark_service(service_to_stop, &STOPPED); */
         return (FALSE);
     }
 
+    /* check if its currently allredy down */
+    if (IS_DOWN(service_to_stop))
+    {
+	D_("Service %s is down allredy.\n", service_to_stop->name);
+	return (TRUE);
+    }
+    
     /* make sure the service is up */
     if (!IS_UP(service_to_stop))
     {
-        D_("Service %s is not up but %s, and will be force set to STOPPED.\n",
+        W_("Service %s is not up but %s, and cant be stopped.\n",
            service_to_stop->name, service_to_stop->current_state->state_name);
 
-        /* why we should mark it as fail stopping if it's not running at all?!? */
-        initng_common_mark_service(service_to_stop, &STOPPED);
-        return (TRUE);
+        return (FALSE);
     }
 
     /* if stop_service code is included in type, use it. */
-    if (service_to_stop->type->stop_service)
-        return ((*service_to_stop->type->stop_service) (service_to_stop));
-
-    W_("Service %s Type %s  has no stopper, will return FALSE!\n",
-       service_to_stop->name, service_to_stop->type->name);
-    return (FALSE);
+    if (!service_to_stop->type->stop_service)
+    {
+	W_("Service %s Type %s  has no stopper, will return FALSE!\n",
+          service_to_stop->name, service_to_stop->type->name);
+	return (FALSE);
+    }
+    
+    
+    return ((*service_to_stop->type->stop_service) (service_to_stop));
 }
 
 int initng_handler_restart_service(active_db_h * service_to_restart)
@@ -275,6 +297,12 @@
     if (!service_to_restart->type)
         return (FALSE);
 
+    if(!IS_UP(service_to_restart))
+    {
+	F_("Can only restart a running service.\n");
+	return(FALSE);
+    }
+    
     /* if there exits a restart code, use it */
     if (service_to_restart->type->restart_service)
         return ((*service_to_restart->type->
@@ -339,6 +367,10 @@
         /* don't stop a stopping service */
         if (IS_STOPPING(ser))
             continue;
+	if (IS_DOWN(ser))
+	    continue;
+	if (IS_FAILED(ser))
+	    continue;
 
         /* stop services */
         initng_handler_stop_service(ser);


More information about the Initng-svn mailing list