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

[Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c p ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland sourceware org	2006-08-31 19:13:02

Modified files:
	group/gfs_controld: lock_dlm.h main.c plock.c 

Log message:
	convert write(2) calls to use do_write() which handles EINTR and
	short writes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/lock_dlm.h.diff?cvsroot=cluster&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/plock.c.diff?cvsroot=cluster&r1=1.19&r2=1.20

--- cluster/group/gfs_controld/lock_dlm.h	2006/08/21 17:46:19	1.16
+++ cluster/group/gfs_controld/lock_dlm.h	2006/08/31 19:13:02	1.17
@@ -243,6 +243,7 @@
 	char buf[0];
 };
 
+int do_write(int fd, void *buf, size_t count);
 struct mountgroup *find_mg(char *name);
 struct mountgroup *find_mg_id(uint32_t id);
 
--- cluster/group/gfs_controld/main.c	2006/08/31 18:46:24	1.12
+++ cluster/group/gfs_controld/main.c	2006/08/31 19:13:02	1.13
@@ -35,6 +35,28 @@
 extern struct list_head withdrawn_mounts;
 int no_withdraw;
 
+
+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) {
+		log_error("write errno %d", errno);
+		return rv;
+	}
+
+	if (rv != count) {
+		count -= rv;
+		off += rv;
+		goto retry;
+	}
+	return 0;
+}
+
 #if 0
 static void make_args(char *buf, int *argc, char **argv, char sep)
 {
@@ -134,24 +156,20 @@
 
 int client_send(int ci, char *buf, int len)
 {
-	return write(client[ci].fd, buf, len);
+	return do_write(client[ci].fd, buf, len);
 }
 
 static int dump_debug(int ci)
 {
-	int rv, len;
+	int len;
 
 	if (dump_wrap) {
 		len = DUMP_SIZE - dump_point;
-		rv = write(client[ci].fd, dump_buf + dump_point, len);
-		if (rv != len)
-			log_debug("write error %d errno %d", rv, errno);
+		do_write(client[ci].fd, dump_buf + dump_point, len);
 	}
 	len = dump_point;
 
-	rv = write(client[ci].fd, dump_buf, len);
-	if (rv != len)
-		log_debug("write error %d errno %d", rv, errno);
+	do_write(client[ci].fd, dump_buf, len);
 	return 0;
 }
 
--- cluster/group/gfs_controld/plock.c	2006/08/21 17:46:19	1.19
+++ cluster/group/gfs_controld/plock.c	2006/08/31 19:13:02	1.20
@@ -1451,7 +1451,7 @@
 			      po->start, po->end,
 			      po->nodeid, po->pid, po->owner);
 
-			rv = write(fd, line, strlen(line));
+			rv = do_write(fd, line, strlen(line));
 		}
 
 		list_for_each_entry(w, &r->waiters, list) {
@@ -1462,7 +1462,7 @@
 			      w->info.start, w->info.end,
 			      w->info.nodeid, w->info.pid, w->info.owner);
 
-			rv = write(fd, line, strlen(line));
+			rv = do_write(fd, line, strlen(line));
 		}
 	}
 


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