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

[Cluster-devel] cluster fence/fenced/group.c fence/fenced/main ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	teigland sourceware org	2007-10-26 20:34:43

Modified files:
	fence/fenced   : group.c main.c member_cman.c 
	group/daemon   : main.c 
	group/gfs_controld: main.c 
	group/lib      : libgroup.c 
	group/tool     : main.c 

Log message:
	Improve the dumping of debug logs from daemons.
	bz 317181
	
	group_tool reads debug logs from groupd, fenced, and gfs_controld.
	The dumping code in all three daemons is now identical.  The other
	change is that the dumping function terminates the final write
	with \0, and no longer sends the entire 1MB log buffer if it's not full.
	
	(Plus a couple random bits to sync with HEAD)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/group.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.10&r2=1.10.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.38.2.4&r2=1.38.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/member_cman.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.15.2.2&r2=1.15.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/daemon/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.51.2.7&r2=1.51.2.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.18.2.12&r2=1.18.2.13
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/lib/libgroup.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.24.2.1&r2=1.24.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.21.2.3&r2=1.21.2.4

--- cluster/fence/fenced/group.c	2006/10/13 16:03:47	1.10
+++ cluster/fence/fenced/group.c	2007/10/26 20:34:37	1.10.2.1
@@ -161,7 +161,7 @@
 
 	gh = group_init(NULL, "fence", 0, &callbacks, GROUPD_TIMEOUT);
 	if (!gh) {
-		log_error("group_init error %d %d", (int) gh, errno);
+		log_error("group_init error %p %d", gh, errno);
 		return -ENOTCONN;
 	}
 	rv = group_get_fd(gh);
--- cluster/fence/fenced/main.c	2007/10/01 16:32:26	1.38.2.4
+++ cluster/fence/fenced/main.c	2007/10/26 20:34:38	1.38.2.5
@@ -338,21 +338,22 @@
 		client[i].fd = -1;
 }
 
-static int do_dump(int ci)
+static int do_dump(int fd)
 {
-	int rv, len = DUMP_SIZE;
+	int len;
 
 	if (dump_wrap) {
 		len = DUMP_SIZE - dump_point;
-		rv = do_write(client[ci].fd, dump_buf + dump_point, len);
-		if (rv < 0)
-			log_debug("write error %d errno %d", rv, errno);
+		do_write(fd, dump_buf + dump_point, len);
+		len = dump_point;
+	} else
 		len = dump_point;
-	}
 
-	rv = do_write(client[ci].fd, dump_buf, len);
-	if (rv < 0)
-		log_debug("write error %d errno %d", rv, errno);
+	/* NUL terminate the debug string */
+	dump_buf[dump_point] = '\0';
+
+	do_write(fd, dump_buf, len);
+
 	return 0;
 }
 
@@ -386,7 +387,8 @@
 	else if (!strcmp(cmd, "leave"))
 		rv = do_leave(name);
 	else if (!strcmp(cmd, "dump")) {
-		do_dump(ci);
+		do_dump(client[ci].fd);
+		close(client[ci].fd);
 		return 0;
 	} else
 		rv = -EINVAL;
--- cluster/fence/fenced/member_cman.c	2007/08/31 14:26:04	1.15.2.2
+++ cluster/fence/fenced/member_cman.c	2007/10/26 20:34:38	1.15.2.3
@@ -123,7 +123,7 @@
 
 	ch = cman_init(NULL);
 	if (!ch) {
-		log_error("cman_init error %d %d", (int) ch, errno);
+		log_error("cman_init error %p %d", ch, errno);
 		return -ENOTCONN;
 	}
 
--- cluster/group/daemon/main.c	2007/09/07 19:22:08	1.51.2.7
+++ cluster/group/daemon/main.c	2007/10/26 20:34:39	1.51.2.8
@@ -553,19 +553,20 @@
 
 static int do_dump(int fd)
 {
-	int rv, len = DUMP_SIZE;
+	int len;
 
 	if (dump_wrap) {
 		len = DUMP_SIZE - dump_point;
-		rv = do_write(fd, dump_buf + dump_point, len);
-		if (rv < 0)
-			log_print("dump write error %d errno %d", rv, errno);
+		do_write(fd, dump_buf + dump_point, len);
+		len = dump_point;
+	} else
 		len = dump_point;
-	}
 
-	rv = do_write(fd, dump_buf, len);
-	if (rv < 0)
-		log_print("dump write error %d errno %d", rv, errno);
+	/* NUL terminate the debug string */
+	dump_buf[dump_point] = '\0';
+
+	do_write(fd, dump_buf, len);
+
 	return 0;
 }
 
@@ -667,6 +668,7 @@
 
 	case DO_DUMP:
 		do_dump(client[ci].fd);
+		close(client[ci].fd);
 		break;
 
 	case DO_LOG:
--- cluster/group/gfs_controld/main.c	2007/06/12 20:05:12	1.18.2.12
+++ cluster/group/gfs_controld/main.c	2007/10/26 20:34:40	1.18.2.13
@@ -255,17 +255,22 @@
 	return do_write(client[ci].fd, buf, len);
 }
 
-static int dump_debug(int ci)
+static int do_dump(int fd)
 {
-	int len = DUMP_SIZE;
+	int len;
 
 	if (dump_wrap) {
 		len = DUMP_SIZE - dump_point;
-		do_write(client[ci].fd, dump_buf + dump_point, len);
+		do_write(fd, dump_buf + dump_point, len);
 		len = dump_point;
-	}
+	} else
+		len = dump_point;
+
+	/* NUL terminate the debug string */
+	dump_buf[dump_point] = '\0';
+
+	do_write(fd, dump_buf, len);
 
-	do_write(client[ci].fd, dump_buf, len);
 	return 0;
 }
 
@@ -375,7 +380,8 @@
 		goto reply;
 
 	} else if (!strcmp(cmd, "dump")) {
-		dump_debug(ci);
+		do_dump(client[ci].fd);
+		close(client[ci].fd);
 
 	} else if (!strcmp(cmd, "plocks")) {
 		dump_plocks(argv[1], client[ci].fd);
--- cluster/group/lib/libgroup.c	2006/11/17 16:30:45	1.24.2.1
+++ cluster/group/lib/libgroup.c	2007/10/26 20:34:41	1.24.2.2
@@ -378,7 +378,7 @@
 {
 	char buf[GROUPD_MSGLEN], *argv[MAXARGS];
 	char *p;
-	int act, argc, rv, i, count, *nodeids;
+	int act, argc, rv, count, *nodeids;
 	struct group_handle *h = (struct group_handle *) handle;
 	VALIDATE_HANDLE(h);
 
@@ -494,7 +494,7 @@
 {
 	char buf[GROUPD_MSGLEN];
 	char data_buf[sizeof(group_data_t)];
-	int fd, rv, len;
+	int fd, rv;
 
 	fd = connect_groupd();
 	if (fd < 0)
--- cluster/group/tool/main.c	2006/12/01 15:26:40	1.21.2.3
+++ cluster/group/tool/main.c	2007/10/26 20:34:42	1.21.2.4
@@ -379,10 +379,8 @@
 		return -1;
 	}
 
-	rv = do_read(fd, inbuf, sizeof(inbuf));
-	if (rv < 0)
-		printf("dump read error %d errno %d\n", rv, errno);
-	do_write(STDOUT_FILENO, inbuf, sizeof(inbuf));
+	do_read(fd, inbuf, sizeof(inbuf));
+	do_write(STDOUT_FILENO, inbuf, strlen(inbuf));
 
 	close(fd);
 	return 0;
@@ -405,9 +403,7 @@
 		return -1;
 	}
 
-	rv = do_read(fd, inbuf, sizeof(inbuf));
-	if (rv < 0)
-		printf("dump read error %d errno %d\n", rv, errno);
+	do_read(fd, inbuf, sizeof(inbuf));
 	do_write(STDOUT_FILENO, inbuf, sizeof(inbuf));
 
 	close(fd);


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