cluster: STABLE3 - cman: check for new config only once per second

Jan Friesse honzaf at fedoraproject.org
Thu Jul 22 11:49:32 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=ea72ab5e568caa0dff9318df22f990463fb29e43
Commit:        ea72ab5e568caa0dff9318df22f990463fb29e43
Parent:        6859554b766ba192a10b7fd456f47a3ed957feb9
Author:        Jan Friesse <jfriesse at redhat.com>
AuthorDate:    Thu Jul 22 13:48:37 2010 +0200
Committer:     Jan Friesse <jfriesse at redhat.com>
CommitterDate: 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.
---
 cman/daemon/commands.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index 2f62616..058cc87 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);
@@ -1198,8 +1199,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);
@@ -1212,6 +1215,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;


More information about the cluster-commits mailing list