[Cluster-devel] cluster/cman/cman_tool join.c

pcaulfield at sourceware.org pcaulfield at sourceware.org
Tue Dec 12 16:51:12 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	pcaulfield at sourceware.org	2006-12-12 16:51:11

Modified files:
	cman/cman_tool : join.c 

Log message:
	Fix minor bug where cman_tool join didn't spot that aisexec had started
	correctly or crashed.
	
	This means we can up the timer for allowing aisexec to start with no ill
	effects. see bz#218688

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/cman_tool/join.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.47&r2=1.47.2.1

--- cluster/cman/cman_tool/join.c	2006/08/11 12:34:18	1.47
+++ cluster/cman/cman_tool/join.c	2006/12/12 16:51:10	1.47.2.1
@@ -11,6 +11,7 @@
 *******************************************************************************
 ******************************************************************************/
 
+#include <sys/wait.h>
 #include <stdint.h>
 #include <signal.h>
 #include <netinet/in.h>
@@ -148,6 +149,7 @@
 
 	/* Give the daemon a chance to start up, and monitor the pipe FD for messages */
 	i = 0;
+	close(p[1]);
 	do {
 		fd_set fds;
 		struct timeval tv={1, 0};
@@ -158,13 +160,6 @@
 		FD_SET(p[0], &fds);
 
 		status = select(p[0]+1, &fds, NULL, NULL, &tv);
-		if (status == 0) {
-			h = cman_admin_init(NULL);
-			if (!h && comline->verbose)
-			{
-				fprintf(stderr, "waiting for aisexec to start\n");
-			}
-		}
 
 		/* Did we get an error? */
 		if (status == 1) {
@@ -172,9 +167,22 @@
 				fprintf(stderr, "cman not started: %s\n", message);
 				break;
 			}
-
+			else {
+				int pidstatus;
+				if (waitpid(aisexec_pid, &pidstatus, WNOHANG) == 0)
+					fprintf(stderr, "cman died with status: %d\n", WEXITSTATUS(pidstatus));
+				else
+					status = 0; /* Try to connect */
+			}
+		}
+		if (status == 0) {
+			h = cman_admin_init(NULL);
+			if (!h && comline->verbose)
+			{
+				fprintf(stderr, "waiting for aisexec to start\n");
+			}
 		}
-	} while (!h && ++i < 20);
+	} while (!h && ++i < 100);
 
 	if (!h)
 		die("aisexec daemon didn't start");




More information about the Cluster-devel mailing list