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

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



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland sourceware org	2006-12-01 15:28:12

Modified files:
	fence/fenced   : main.c 

Log message:
	group_tool dump doesn't handle partial reads/writes,
	now we always dump entire fixed size debug buffer
	bz 214540

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/fenced/main.c.diff?cvsroot=cluster&r1=1.39&r2=1.40

--- cluster/fence/fenced/main.c	2006/11/30 23:56:03	1.39
+++ cluster/fence/fenced/main.c	2006/12/01 15:28:11	1.40
@@ -33,6 +33,43 @@
 commandline_t comline;
 struct list_head domains;
 
+static int do_write(int fd, void *buf, size_t count)
+{
+	int rv, off = 0;
+
+ retry:
+	rv = write(fd, buf + off, count);
+	if (rv == -1 && errno == EINTR)
+		goto retry;
+	if (rv < 0)
+		return rv;
+
+	if (rv != count) {
+		count -= rv;
+		off += rv;
+		goto retry;
+	}
+	return 0;
+}
+
+/*
+static int do_read(int fd, void *buf, size_t count)
+{
+	int rv, off = 0;
+
+	while (off < count) {
+		rv = read(fd, buf + off, count - off);
+		if (rv == 0)
+			return -1;
+		if (rv == -1 && errno == EINTR)
+			continue;
+		if (rv == -1)
+			return -1;
+		off += rv;
+	}
+	return 0;
+}
+*/
 
 static int setup_ccs(fd_t *fd)
 {
@@ -286,18 +323,18 @@
 
 static int do_dump(int ci)
 {
-	int rv, len;
+	int rv, len = DUMP_SIZE;
 
 	if (dump_wrap) {
 		len = DUMP_SIZE - dump_point;
-		rv = write(client[ci].fd, dump_buf + dump_point, len);
-		if (rv != len)
+		rv = do_write(client[ci].fd, dump_buf + dump_point, len);
+		if (rv < 0)
 			log_debug("write error %d errno %d", rv, errno);
+		len = dump_point;
 	}
-	len = dump_point;
 
-	rv = write(client[ci].fd, dump_buf, len);
-	if (rv != len)
+	rv = do_write(client[ci].fd, dump_buf, len);
+	if (rv < 0)
 		log_debug("write error %d errno %d", rv, errno);
 	return 0;
 }


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