All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/fence/fenced agent.c fd.h recover.c
Date: 26 Oct 2007 20:36:49 -0000	[thread overview]
Message-ID: <20071026203649.21013.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rmccabe at sourceware.org	2007-10-26 20:36:49

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

Log message:
	patch from Marco Ceci to fix 354421

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/agent.c.diff?cvsroot=cluster&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/fd.h.diff?cvsroot=cluster&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/recover.c.diff?cvsroot=cluster&r1=1.29&r2=1.30

--- cluster/fence/fenced/agent.c	2007/10/26 18:46:16	1.18
+++ cluster/fence/fenced/agent.c	2007/10/26 20:36:49	1.19
@@ -302,11 +302,23 @@
 	cman_finish(ch);
 }
 
-int dispatch_fence_agent(int cd, char *victim)
+int dispatch_fence_agent(char *victim, int force)
 {
 	char *method = NULL, *device = NULL;
 	char *victim_nodename = 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;
+	}
 
 	if (ccs_lookup_nodename(cd, victim, &victim_nodename) == 0)
 		victim = victim_nodename;
@@ -316,8 +328,23 @@
 	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;
@@ -348,6 +375,8 @@
 			break;
 	}
 
+	ccs_disconnect(cd);
+
 	return error;
 }
 
--- cluster/fence/fenced/fd.h	2007/02/22 16:12:42	1.26
+++ cluster/fence/fenced/fd.h	2007/10/26 20:36:49	1.27
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **  
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -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:47	1.29
+++ cluster/fence/fenced/recover.c	2007/10/26 20:36:49	1.30
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -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,



             reply	other threads:[~2007-10-26 20:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-26 20:36 rmccabe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-10-26 18:05 [Cluster-devel] cluster/fence/fenced agent.c fd.h recover.c rmccabe
2006-12-01 19:57 rohara
2006-12-01 19:17 rohara
2006-07-10 17:02 rohara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071026203649.21013.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.