[Initng-svn] r2999 - initng/plugins/daemon

svn at initng.thinktux.net svn at initng.thinktux.net
Thu Feb 16 01:25:15 CET 2006


Author: jimmy
Date: Thu Feb 16 01:25:14 2006
New Revision: 2999

Modified:
   initng/plugins/daemon/initng_daemon.c
Log:
Switch killand term.


Modified: initng/plugins/daemon/initng_daemon.c
==============================================================================
--- initng/plugins/daemon/initng_daemon.c	(original)
+++ initng/plugins/daemon/initng_daemon.c	Thu Feb 16 01:25:14 2006
@@ -87,12 +87,12 @@
 /*
  * Seconds a process have to exit after kill signal sent, before term is sent.
  */
-#define DEFAULT_KILL_TIMEOUT 6
+#define DEFAULT_KILL_TIMEOUT 2
 
 /*
  * Seconds a process have to exit after term signal sent.
  */
-#define DEFAULT_TERM_TIMEOUT 2
+#define DEFAULT_TERM_TIMEOUT 6
 
 /*
  * ############################################################################
@@ -198,11 +198,11 @@
 };
 
 /*
- * Kill timeout, when killing the daemon, wait this many seconds, before
- * Sending the TERM signal, if this is 0, the TERM signal will be sent directly.
+ * TERM timeout, when killing the daemon, wait this many seconds, before
+ * Sending the KILL signal.
  */
-s_entry KILL_TIMEOUT = { "kill_timeout", INT, &TYPE_DAEMON,
-    "Wait this many seconds before TERM daemon, after a KILL." };
+s_entry TERM_TIMEOUT = { "term_timeout", INT, &TYPE_DAEMON,
+    "Wait this many seconds before KILL daemon, after a TERM." };
 
 /*
  * Down here, internal variables, that we use, but cant be set in the .i file.
@@ -365,7 +365,7 @@
     initng_service_data_types_add(&PIDOF);
     initng_service_data_types_add(&FORKS);
     initng_service_data_types_add(&RESPAWN);
-    initng_service_data_types_add(&KILL_TIMEOUT);
+    initng_service_data_types_add(&TERM_TIMEOUT);
     initng_service_data_types_add(&INTERNAL_GOT_PID);
     initng_service_data_types_add(&INTERNAL_PIDFILE_TIMEOUT);
     initng_service_data_types_add(&INTERNAL_PID_WARN_TIME);
@@ -424,7 +424,7 @@
     initng_service_data_types_del(&PIDOF);
     initng_service_data_types_del(&FORKS);
     initng_service_data_types_del(&RESPAWN);
-    initng_service_data_types_del(&KILL_TIMEOUT);
+    initng_service_data_types_del(&TERM_TIMEOUT);
     initng_service_data_types_del(&INTERNAL_GOT_PID);
     initng_service_data_types_del(&INTERNAL_PIDFILE_TIMEOUT);
     initng_service_data_types_del(&INTERNAL_PID_WARN_TIME);
@@ -544,11 +544,11 @@
     process_h *process = NULL;
     int timeout;
 
-    /* get the KILL_TIMEOUT */
-    timeout=initng_active_db_get_int(&KILL_TIMEOUT, service);
+    /* get the TERM_TIMEOUT */
+    timeout=initng_active_db_get_int(&TERM_TIMEOUT, service);
 
     if(timeout==0)
-	timeout = DEFAULT_KILL_TIMEOUT;
+	timeout = DEFAULT_TERM_TIMEOUT;
 
     /* find the daemon, and check so it still exits */
     if(!(process=initng_process_db_get(&T_DAEMON, service)))
@@ -585,14 +585,14 @@
             /* if there is no plugin that wanna kill this daemon,
              * we do it ourself.
              */
-    	    kill_daemon(service, SIGKILL);
-	    if(!initng_common_mark_service(service, &DAEMON_KILL))
+    	    kill_daemon(service, SIGTERM);
+	    if(!initng_common_mark_service(service, &DAEMON_TERM))
 		return;
             break;
 	}
         default:
 	/* Set its state to GOING_KILLED, to mark that we put some effort on killing it. */
-	    if(!initng_common_mark_service(service, &DAEMON_KILL))
+	    if(!initng_common_mark_service(service, &DAEMON_TERM))
 		return;
             break;
     }
@@ -710,18 +710,18 @@
 }
 
 
-static void handle_DAEMON_KILL(active_db_h * daemon)
+static void handle_DAEMON_TERM(active_db_h * daemon)
 {
     time_t n = time(0);
     int timeout;
     int elap;
     
-    /* get the KILL_TIMEOUT */
-    timeout=initng_active_db_get_int(&KILL_TIMEOUT, daemon);
+    /* get the TERM_TIMEOUT */
+    timeout=initng_active_db_get_int(&TERM_TIMEOUT, daemon);
     
     /* Make sure we got an value */
     if(timeout==0)
-	timeout = DEFAULT_KILL_TIMEOUT;
+	timeout = DEFAULT_TERM_TIMEOUT;
     
     /* calculate time gone */
     elap=n-daemon->time_current_state.tv_sec;
@@ -729,15 +729,15 @@
     /* check if its to mutch */
     if(elap>=timeout)
     {
-	F_("Service %s KILL_TIMEOUT of %i seconds reached! (%i seconds passed), sending TERM signal.\n", daemon->name, timeout, elap);
-	kill_daemon(daemon, SIGTERM);
+	F_("Service %s TERM_TIMEOUT of %i seconds reached! (%i seconds passed), sending KILL signal.\n", daemon->name, timeout, elap);
+	kill_daemon(daemon, SIGKILL);
 	
 	/* Set it to DAEMON_TERM state, monitoring that TERM signal is sent. */
-	if(!initng_common_mark_service(daemon, &DAEMON_TERM))
+	if(!initng_common_mark_service(daemon, &DAEMON_KILL))
 	    return;
 	    
 	/* make sure handle_DAEMON_TERM is run */
-	initng_global_set_sleep(DEFAULT_TERM_TIMEOUT);
+	initng_global_set_sleep(DEFAULT_KILL_TIMEOUT);
 
 	return;
     }
@@ -747,18 +747,18 @@
 }
 
 
-static void handle_DAEMON_TERM(active_db_h * daemon)
+static void handle_DAEMON_KILL(active_db_h * daemon)
 {
     time_t n = time(0);
     int elap=n-daemon->time_current_state.tv_sec;
 
-    if(elap>=DEFAULT_TERM_TIMEOUT)
+    if(elap>=DEFAULT_KILL_TIMEOUT)
     {
-	F_("Service %s TERM_TIMEOUT of %i seconds reached! (%i seconds passed), sending another TERM signal.\n", daemon->name, DEFAULT_TERM_TIMEOUT, elap);
-	kill_daemon(daemon, SIGTERM);
+	F_("Service %s KILL_TIMEOUT of %i seconds reached! (%i seconds passed), sending another TERM signal.\n", daemon->name, DEFAULT_KILL_TIMEOUT, elap);
+	kill_daemon(daemon, SIGKILL);
 	
-	/* make sure handle_DAEMON_TERM will be run */
-	initng_global_set_sleep(DEFAULT_TERM_TIMEOUT);
+	/* make sure handle_DAEMON_KILL will be run */
+	initng_global_set_sleep(DEFAULT_KILL_TIMEOUT);
 	return;
     }
 


More information about the Initng-svn mailing list