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

[Cluster-devel] cluster/fence/fenced agent.c fd.h recover.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rmccabe sourceware org	2007-10-26 18:05:43

Modified files:
	fence/fenced   : agent.c fd.h recover.c 

Log message:
	Applying patch from Marco Ceci to fix 354421

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/agent.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.15.2.1&r2=1.15.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/fd.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.24.2.2&r2=1.24.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/recover.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.25.2.4&r2=1.25.2.5

--- cluster/fence/fenced/agent.c	2006/12/01 19:17:46	1.15.2.1
+++ cluster/fence/fenced/agent.c	2007/10/26 18:05:42	1.15.2.2
@@ -302,18 +302,45 @@
 	cman_finish(ch);
 }
 
-int dispatch_fence_agent(int cd, char *victim)
+int dispatch_fence_agent(char *victim, int force)
 {
 	char *method = NULL, *device = NULL;
-	int num_methods, num_devices, m, d, error = -1;
+	int num_methods, num_devices, m, d, error = -1, cd;
+
+	if (force)
+		cd = ccs_force_connect(NULL, 0);
+	else {
+		while ((cd = ccs_connect()) < 0)
+			sleep(1);
+	}
+
+	if (cd < 0) {
+		syslog(LOG_ERR, "cannot connect to ccs %d\n", cd);
+		return -1;
+	}
 
 	num_methods = count_methods(cd, victim);
 
 	for (m = 0; m < num_methods; m++) {
 
 		error = get_method(cd, victim, m, &method);
+
+		/* if the connection timed out while we were trying 
+		 * to fence, try to open the connection again
+		 */
+		if (error == -EBADR) {
+			syslog(LOG_INFO, "ccs connection timed out, "
+				"retrying\n");
+
+			while ((cd = ccs_connect()) < 0)
+				sleep(1);
+			
+			error = get_method(cd, victim, m, &method);
+
 		if (error)
 			continue;
+		} else if (error)
+			continue;
 
 		/* if num_devices is zero we should return an error */
 		error = -1;
@@ -342,6 +369,8 @@
 			break;
 	}
 
+	ccs_disconnect(cd);
+
 	return error;
 }
 
--- cluster/fence/fenced/fd.h	2007/01/29 20:30:25	1.24.2.2
+++ cluster/fence/fenced/fd.h	2007/10/26 18:05:42	1.24.2.3
@@ -176,7 +176,7 @@
 void do_recovery_done(fd_t *fd);
 
 /* agent.c */
-int dispatch_fence_agent(int cd, char *victim);
+int dispatch_fence_agent(char *victim, int force);
 
 /* group.c */
 int setup_groupd(void);
--- cluster/fence/fenced/recover.c	2007/09/18 20:53:17	1.25.2.4
+++ cluster/fence/fenced/recover.c	2007/10/26 18:05:42	1.25.2.5
@@ -12,7 +12,6 @@
 ******************************************************************************/
 
 #include "fd.h"
-#include "ccs.h"
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/select.h>
@@ -359,7 +358,7 @@
 {
 	fd_node_t *node;
 	char *master_name;
-	int master, error, cd;
+	int master, error;
 	int override = -1;
 
 	master = find_master_nodeid(fd, &master_name);
@@ -372,9 +371,6 @@
 
 	delay_fencing(fd, start_type);
 
-	while ((cd = ccs_connect()) < 0)
-		sleep(1);
-
 	while (!list_empty(&fd->victims)) {
 		node = list_entry(fd->victims.next, fd_node_t, list);
 
@@ -388,7 +384,7 @@
 		log_debug("fencing node %s", node->name);
 		syslog(LOG_INFO, "fencing node \"%s\"", node->name);
 
-		error = dispatch_fence_agent(cd, node->name);
+		error = dispatch_fence_agent(node->name, 0);
 
 		syslog(LOG_INFO, "fence \"%s\" %s", node->name,
 		       error ? "failed" : "success");
@@ -415,8 +411,6 @@
 		}
 		close_override(&override, comline.override_path);
 	}
-
-	ccs_disconnect(cd);
 }
 
 static void add_victims(fd_t *fd, int start_type, int member_count,


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