Skip to contentSkip to conversation

cluster/cman/daemon cmanccs.c

Cluster-devel [email protected] 1 participant 1 message Mar 15, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: pcaulfield at sourceware.org 2007-03-15 11:12:33

Modified files:
cman/daemon : cmanccs.c

Log message:
If the machine is multi-homed, then using a truncated name in uname but not in cluster.conf would fail to match them up.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.25&r2=1.26

cman/daemon/cmanccs.c +16 -13
@@ -313,14 +313,17 @@
 		free(str);
 	}
 
-
 	/* The cluster.conf names may not be related to uname at all,
-	   they may match a hostname on some network interface */
+	   they may match a hostname on some network interface.
+	   NOTE: This is IPv4 only */
 	error = getifaddrs(&ifa_list);
 	if (error)
 		return -1;
 
 	for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
+
+		/* Restore this */
+		strcpy(nodename2, nodename);
 		sa = ifa->ifa_addr;
 		if (!sa || sa->sa_family != AF_INET)
 			continue;
@@ -341,11 +344,12 @@
 			goto out;
 		}
 
-		/* See if it's the IP address that's in cluster.conf */
-		error = getnameinfo(sa, sizeof(*sa), nodename2,
-				    sizeof(nodename2), NULL, 0, NI_NUMERICHOST);
-		if (error)
-			goto out;
+		/* truncate this name and try again */
+
+		dot = strstr(nodename2, ".");
+		if (!dot)
+			continue;
+		*dot = '\0';
 
 		str = NULL;
 		memset(path, 0, 256);
@@ -358,12 +362,11 @@
 			goto out;
 		}
 
-		/* truncate this name and try again */
-
-		dot = strstr(nodename2, ".");
-		if (!dot)
-			continue;
-		*dot = '\0';
+		/* See if it's the IP address that's in cluster.conf */
+		error = getnameinfo(sa, sizeof(*sa), nodename2,
+				    sizeof(nodename2), NULL, 0, NI_NUMERICHOST);
+		if (error)
+			goto out;
 
 		str = NULL;
 		memset(path, 0, 256);