A new user interface for you! Read more...

File cman_check_config_only_once_per_sec.patch of Package cluster

commit 48da29636cd862a012e38ef4860d2d4e99aede4d
Author: Jan Friesse <jfriesse@redhat.com>
Date:   Thu Jul 22 13:48:37 2010 +0200

    cman: check for new config only once per second
    
    This patch fixes a condition where user calls cman_tool version
    multiple times where version is non existing multiple times.
    
    This will cause addition of many corosync_timers and new configuration
    is then tested every 1/(no. calls) sec, instead of (default) 1sec. If
    fraction is really small, corosync will keep reloading file using 100%
    CPU time and doing nothing else.
    
    Resolves: rhbz#616222

diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index c223a81..604e400 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -85,6 +85,7 @@ static uint32_t shutdown_flags;
 static int shutdown_yes;
 static int shutdown_no;
 static int shutdown_expected;
+static int ccsd_timer_active = 0;
 
 static struct cluster_node *find_node_by_nodeid(int nodeid);
 static struct cluster_node *find_node_by_name(char *name);
@@ -1206,8 +1207,10 @@ static int reread_config(int new_version)
 
 	/* Keep looking */
 	if (read_err || config_version < wanted_config_version) {
-		corosync->timer_add_duration((unsigned long long)ccsd_poll_interval*1000000, NULL,
-					     ccsd_timer_fn, &ccsd_timer);
+		if (!ccsd_timer_active)
+			corosync->timer_add_duration((unsigned long long)ccsd_poll_interval*1000000, NULL,
+						     ccsd_timer_fn, &ccsd_timer);
+		ccsd_timer_active = 1;
 	}
 	else {
 		recalculate_quorum(1, 0);
@@ -1220,6 +1223,9 @@ static int reread_config(int new_version)
 static void ccsd_timer_fn(void *arg)
 {
 	log_printf(LOG_DEBUG, "Polling configuration for updated information\n");
+
+	ccsd_timer_active = 0;
+
 	if (!reread_config(wanted_config_version) && config_version >= wanted_config_version) {
 		log_printf(LOG_ERR, "Now got config information version %d, continuing\n", config_version);
 		config_error = 0;