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

[Cluster-devel] cluster/group/tool main.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland sourceware org	2006-07-13 18:15:43

Modified files:
	group/tool     : main.c 

Log message:
	fix up group_tool dump which was broken

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/tool/main.c.diff?cvsroot=cluster&r1=1.15&r2=1.16

--- cluster/group/tool/main.c	2006/06/28 19:58:32	1.15
+++ cluster/group/tool/main.c	2006/07/13 18:15:43	1.16
@@ -20,6 +20,7 @@
 #include <stddef.h>
 #include <fcntl.h>
 #include <string.h>
+#include <errno.h>
 #include <netinet/in.h>
 
 #include "libgroup.h"
@@ -293,20 +294,26 @@
 
 int do_dump(int argc, char **argv)
 {
-	char buf[DUMP_SIZE];
+	char inbuf[DUMP_SIZE];
+	char outbuf[GROUPD_MSGLEN];
 	int rv, fd = connect_groupd();
 
-	rv = write(fd, "dump", 4);
-	if (rv != 4)
-		return -1;
+	memset(inbuf, 0, sizeof(inbuf));
+	memset(outbuf, 0, sizeof(outbuf));
 
-	memset(buf, 0, sizeof(buf));
+	sprintf(outbuf, "dump");
 
-	rv = read(fd, buf, sizeof(buf));
-	if (rv <= 0)
-		return rv;
+	rv = write(fd, outbuf, sizeof(outbuf));
+	if (rv != sizeof(outbuf)) {
+		printf("dump write error %d errno %d\n", rv, errno);;
+		return -1;
+	}
 
-	write(STDOUT_FILENO, buf, rv);
+	rv = read(fd, inbuf, sizeof(inbuf));
+	if (rv <= 0)
+		printf("dump read returned %d errno %d\n", rv, errno);
+	else
+		write(STDOUT_FILENO, inbuf, rv);
 
 	close(fd);
 	return 0;


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