[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.06-32-g9d2109d



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=9d2109d1559a9bb9bb29a7178d084ab744bdc1a1

The branch, master has been updated
       via  9d2109d1559a9bb9bb29a7178d084ab744bdc1a1 (commit)
      from  bbc505c95648f60e698c2eb19d0fc429bcc5bd80 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9d2109d1559a9bb9bb29a7178d084ab744bdc1a1
Author: David Teigland <teigland redhat com>
Date:   Fri Jul 18 10:34:00 2008 -0500

    fenced: munge config option code
    
    to match the code in other daemons.
    
    Signed-off-by: David Teigland <teigland redhat com>

-----------------------------------------------------------------------

Summary of changes:
 fence/fenced/config.c  |   66 ++++++++++++++++++++++++++++-------------------
 fence/fenced/config.h  |   26 +++++++++++++++++++
 fence/fenced/fd.h      |   28 --------------------
 fence/fenced/main.c    |   48 ++++++++++++++---------------------
 fence/fenced/recover.c |   17 ++++++------
 5 files changed, 93 insertions(+), 92 deletions(-)
 create mode 100644 fence/fenced/config.h

diff --git a/fence/fenced/config.c b/fence/fenced/config.c
index 3468459..046112f 100644
--- a/fence/fenced/config.c
+++ b/fence/fenced/config.c
@@ -1,8 +1,27 @@
 #include "fd.h"
+#include "config.h"
 #include "ccs.h"
 
 static int ccs_handle;
 
+/* was a config value set on command line?, 0 or 1. */
+
+int optd_groupd_compat;
+int optd_clean_start;
+int optd_post_join_delay;
+int optd_post_fail_delay;
+int optd_override_time;
+int optd_override_path;
+
+/* actual config value from command line, cluster.conf, or default. */
+
+int cfgd_groupd_compat   = DEFAULT_GROUPD_COMPAT;
+int cfgd_clean_start     = DEFAULT_CLEAN_START;
+int cfgd_post_join_delay = DEFAULT_POST_JOIN_DELAY;
+int cfgd_post_fail_delay = DEFAULT_POST_FAIL_DELAY;
+int cfgd_override_time   = DEFAULT_OVERRIDE_TIME;
+char *cfgd_override_path = DEFAULT_OVERRIDE_PATH;
+
 int setup_ccs(void)
 {
 	int i = 0, cd;
@@ -90,7 +109,7 @@ void read_ccs_int(char *path, int *config_val)
 
 int read_ccs(struct fd *fd)
 {
-	char path[256];
+	char path[PATH_MAX];
 	char *str;
 	int error, i = 0, count = 0;
 
@@ -99,8 +118,8 @@ int read_ccs(struct fd *fd)
 	   fence us. */
 
 	str = NULL;
-	memset(path, 0, 256);
-	snprintf(path, 256, OUR_NAME_PATH, our_name);
+	memset(path, 0, sizeof(path));
+	snprintf(path, sizeof(path), OUR_NAME_PATH, our_name);
 
 	error = ccs_get(ccs_handle, path, &str);
 	if (error || !str) {
@@ -111,44 +130,37 @@ int read_ccs(struct fd *fd)
 	if (str)
 		free(str);
 
-	/* The comline config options are initially set to the defaults,
-	   then options are read from the command line to override the
-	   defaults, for options not set on command line, we look for
-	   values set in cluster.conf. */
-
-	if (!comline.groupd_compat_opt)
-		read_ccs_int(GROUPD_COMPAT_PATH, &comline.groupd_compat);
-	if (!comline.clean_start_opt)
-		read_ccs_int(CLEAN_START_PATH, &comline.clean_start);
-	if (!comline.post_join_delay_opt)
-		read_ccs_int(POST_JOIN_DELAY_PATH, &comline.post_join_delay);
-	if (!comline.post_fail_delay_opt)
-		read_ccs_int(POST_FAIL_DELAY_PATH, &comline.post_fail_delay);
-	if (!comline.override_time_opt)
-		read_ccs_int(OVERRIDE_TIME_PATH, &comline.override_time);
-
-	if (!comline.override_path_opt) {
+	if (!optd_groupd_compat)
+		read_ccs_int(GROUPD_COMPAT_PATH, &cfgd_groupd_compat);
+	if (!optd_clean_start)
+		read_ccs_int(CLEAN_START_PATH, &cfgd_clean_start);
+	if (!optd_post_join_delay)
+		read_ccs_int(POST_JOIN_DELAY_PATH, &cfgd_post_join_delay);
+	if (!optd_post_fail_delay)
+		read_ccs_int(POST_FAIL_DELAY_PATH, &cfgd_post_fail_delay);
+	if (!optd_override_time)
+		read_ccs_int(OVERRIDE_TIME_PATH, &cfgd_override_time);
+
+	if (!optd_override_path) {
 		str = NULL;
-		memset(path, 0, 256);
+		memset(path, 0, sizeof(path));
 		sprintf(path, OVERRIDE_PATH_PATH);
 
 		error = ccs_get(ccs_handle, path, &str);
-		if (!error && str) {
-			free(comline.override_path);
-			comline.override_path = strdup(str);
-		}
+		if (!error && str)
+			cfgd_override_path = strdup(str);
 		if (str)
 			free(str);
 	}
 
-	if (comline.clean_start) {
+	if (cfgd_clean_start) {
 		log_debug("clean start, skipping initial nodes");
 		goto out;
 	}
 
 	for (i = 1; ; i++) {
 		str = NULL;
-		memset(path, 0, 256);
+		memset(path, 0, sizeof(path));
 		sprintf(path, "/cluster/clusternodes/clusternode[%d]/@nodeid", i);
 
 		error = ccs_get(ccs_handle, path, &str);
diff --git a/fence/fenced/config.h b/fence/fenced/config.h
new file mode 100644
index 0000000..3d919ac
--- /dev/null
+++ b/fence/fenced/config.h
@@ -0,0 +1,26 @@
+#ifndef __CONFIG_DOT_H__
+#define __CONFIG_DOT_H__
+
+#define DEFAULT_GROUPD_COMPAT 1
+#define DEFAULT_CLEAN_START 0
+#define DEFAULT_POST_JOIN_DELAY 6
+#define DEFAULT_POST_FAIL_DELAY 0
+#define DEFAULT_OVERRIDE_TIME 3
+#define DEFAULT_OVERRIDE_PATH "/var/run/cluster/fenced_override"
+
+extern int optd_groupd_compat;
+extern int optd_clean_start;
+extern int optd_post_join_delay;
+extern int optd_post_fail_delay;
+extern int optd_override_time;
+extern int optd_override_path;
+
+extern int cfgd_groupd_compat;
+extern int cfgd_clean_start;
+extern int cfgd_post_join_delay;
+extern int cfgd_post_fail_delay;
+extern int cfgd_override_time;
+extern char *cfgd_override_path;
+
+#endif
+
diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h
index 1e91894..e16da90 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -95,34 +95,6 @@ do { \
 	log_printf(lvl, fmt, ##args); \
 } while (0)
 
-/* config option defaults */
-
-#define DEFAULT_GROUPD_COMPAT	1
-#define DEFAULT_CLEAN_START	0
-#define DEFAULT_POST_JOIN_DELAY	6
-#define DEFAULT_POST_FAIL_DELAY	0
-#define DEFAULT_OVERRIDE_TIME   3
-#define DEFAULT_OVERRIDE_PATH	"/var/run/cluster/fenced_override"
-
-struct commandline
-{
-	int groupd_compat;
-	int clean_start;
-	int post_join_delay;
-	int post_fail_delay;
-	int override_time;
-	char *override_path;
-
-	int8_t groupd_compat_opt;
-	int8_t clean_start_opt;
-	int8_t post_join_delay_opt;
-	int8_t post_fail_delay_opt;
-	int8_t override_time_opt;
-	int8_t override_path_opt;
-};
-
-extern struct commandline comline;
-
 #define FD_MSG_START		1
 #define FD_MSG_VICTIM_DONE	2
 #define FD_MSG_COMPLETE		3
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index bc7fb40..decae46 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -1,5 +1,6 @@
 #include "fd.h"
-#include "pthread.h"
+#include "config.h"
+#include <pthread.h>
 #include "copyright.cf"
 
 #define LOCKFILE_NAME		"/var/run/fenced.pid"
@@ -627,7 +628,7 @@ static void loop(void)
 
 	group_mode = GROUP_LIBCPG;
 
-	if (comline.groupd_compat) {
+	if (cfgd_groupd_compat) {
 		rv = setup_groupd();
 		if (rv < 0)
 			goto out;
@@ -635,7 +636,7 @@ static void loop(void)
 
 		group_mode = GROUP_LIBGROUP;
 
-		if (comline.groupd_compat == 2) {
+		if (cfgd_groupd_compat == 2) {
 			/* set_group_mode(); */
 			group_mode = GROUP_LIBGROUP;
 		}
@@ -683,7 +684,7 @@ static void loop(void)
 			break;
 	}
  out:
-	if (comline.groupd_compat)
+	if (cfgd_groupd_compat)
 		close_groupd();
 	close_logging();
 	close_ccs();
@@ -779,37 +780,35 @@ static void read_arguments(int argc, char **argv)
 			break;
 
 		case 'g':
-			comline.groupd_compat = atoi(optarg);
-			comline.groupd_compat_opt = 1;
+			optd_groupd_compat = 1;
+			cfgd_groupd_compat = atoi(optarg);
 			break;
 
 		case 'c':
-			comline.clean_start = 1;
-			comline.clean_start_opt = 1;
+			optd_clean_start = 1;
+			cfgd_clean_start = 1;
 			break;
 
 		case 'j':
-			comline.post_join_delay = atoi(optarg);
-			comline.post_join_delay_opt = 1;
+			optd_post_join_delay = 1;
+			cfgd_post_join_delay = atoi(optarg);
 			break;
 
 		case 'f':
-			comline.post_fail_delay = atoi(optarg);
-			comline.post_fail_delay_opt = 1;
+			optd_post_fail_delay = 1;
+			cfgd_post_fail_delay = atoi(optarg);
 			break;
 
 		case 'R':
-			comline.override_time = atoi(optarg);
-			if (comline.override_time < 3)
-				comline.override_time = 3;
-			comline.override_time_opt = 1;
+			optd_override_time = 1;
+			cfgd_override_time = atoi(optarg);
+			if (cfgd_override_time < 3)
+				cfgd_override_time = 3;
 			break;
 
 		case 'O':
-			if (comline.override_path)
-				free(comline.override_path);
-			comline.override_path = strdup(optarg);
-			comline.override_path_opt = 1;
+			optd_override_path = 1;
+			cfgd_override_path = strdup(optarg);
 			break;
 
 		case 'h':
@@ -857,14 +856,6 @@ int main(int argc, char **argv)
 {
 	INIT_LIST_HEAD(&domains);
 
-	memset(&comline, 0, sizeof(comline));
-	comline.groupd_compat = DEFAULT_GROUPD_COMPAT;
-	comline.clean_start = DEFAULT_CLEAN_START;
-	comline.post_join_delay = DEFAULT_POST_JOIN_DELAY;
-	comline.post_fail_delay = DEFAULT_POST_FAIL_DELAY;
-	comline.override_time = DEFAULT_OVERRIDE_TIME;
-	comline.override_path = strdup(DEFAULT_OVERRIDE_PATH);
-
 	init_logging();
 
 	read_arguments(argc, argv);
@@ -915,5 +906,4 @@ char dump_buf[FENCED_DUMP_SIZE];
 int dump_point;
 int dump_wrap;
 int group_mode;
-struct commandline comline;
 
diff --git a/fence/fenced/recover.c b/fence/fenced/recover.c
index be82190..5b46f36 100644
--- a/fence/fenced/recover.c
+++ b/fence/fenced/recover.c
@@ -1,4 +1,5 @@
 #include "fd.h"
+#include "config.h"
 
 void free_node_list(struct list_head *head)
 {
@@ -164,10 +165,10 @@ void delay_fencing(struct fd *fd, int node_join)
 		return;
 
 	if (node_join) {
-		delay = comline.post_join_delay;
+		delay = cfgd_post_join_delay;
 		delay_type = "post_join_delay";
 	} else {
-		delay = comline.post_fail_delay;
+		delay = cfgd_post_fail_delay;
 		delay_type = "post_fail_delay";
 	}
 
@@ -188,8 +189,8 @@ void delay_fencing(struct fd *fd, int node_join)
 
 		if (victim_count < last_count) {
 			gettimeofday(&start, NULL);
-			if (delay > 0 && comline.post_join_delay > delay) {
-				delay = comline.post_join_delay;
+			if (delay > 0 && cfgd_post_join_delay > delay) {
+				delay = cfgd_post_join_delay;
 				delay_type = "post_join_delay (modified)";
 			}
 		}
@@ -272,7 +273,7 @@ void fence_victims(struct fd *fd)
 			continue;
 		}
 
-		if (!comline.override_path) {
+		if (!cfgd_override_path) {
 			query_unlock();
 			sleep(5);
 			query_lock();
@@ -281,16 +282,16 @@ void fence_victims(struct fd *fd)
 
 		query_unlock();
 		/* Check for manual intervention */
-		override = open_override(comline.override_path);
+		override = open_override(cfgd_override_path);
 		if (check_override(override, node->name,
-				   comline.override_time) > 0) {
+				   cfgd_override_time) > 0) {
 			log_level(LOG_WARNING, "fence \"%s\" overridden by "
 				  "administrator intervention", node->name);
 			victim_done(fd, node->nodeid, VIC_DONE_OVERRIDE);
 			list_del(&node->list);
 			free(node);
 		}
-		close_override(&override, comline.override_path);
+		close_override(&override, cfgd_override_path);
 		query_lock();
 	}
 }


hooks/post-receive
--
Cluster Project


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]