All of lore.kernel.org
 help / color / mirror / Atom feed
From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c p ...
Date: 31 Aug 2006 19:13:03 -0000	[thread overview]
Message-ID: <20060831191303.28246.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at 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));
 		}
 	}
 



             reply	other threads:[~2006-08-31 19:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-31 19:13 teigland [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-11-21 17:28 [Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c p teigland
2006-11-21 17:28 teigland
2006-11-21 17:28 teigland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060831191303.28246.qmail@sourceware.org \
    --to=teigland@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.