[349] in linux-net channel archive

home help back first fref pref prev next nref lref last post

Re: TCP race condition/rdist weirdness

daemon@ATHENA.MIT.EDU (eichin@mit.edu)
Fri May 19 15:19:50 1995

Date: Fri, 19 May 95 11:13:00 -0700
To: Thomas.Koenig@ciw.uni-karlsruhe.de, linux-net@vger.rutgers.edu
In-Reply-To: <9505182355.AA00167@perdiem.cygnus.com> (eichin@MIT.EDU)
From: eichin@mit.edu

Here are the diffs, there have been enough requests to justify
posting. Three files needed changes.
			_Mark_ <eichin@cygnus.com>
			Cygnus Support
			Cygnus Network Security <network-security@cygnus.com>

Index: src/child.c
===================================================================
RCS file: /local/cvsfiles/kerberos/src/appl/rdist/src/child.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- child.c	1995/01/04 22:49:22	1.1.1.1
+++ child.c	1995/03/24 22:44:34	1.2
@@ -203,8 +203,16 @@
 		debugmsg(DM_MISC, "[readchild(%s, %d, %d) got %d bytes]", 
 			 child->c_name, child->c_pid, child->c_readfd, amt);
 
-		write(fileno(stdout), rbuf, amt);
-
+		{
+			int wamt=amt, ramt, woff=0;
+			while ((ramt = write(fileno(stdout), rbuf+woff, wamt)) > 0) {
+				woff += ramt; wamt -= ramt;
+				debugmsg(DM_MISC,
+					 "[readchild(%s, %d, %d) only wrote %d/%d bytes]",
+					 child->c_name, child->c_pid, child->c_readfd, 
+					 ramt, wamt);
+			}
+		}
 		debugmsg(DM_MISC, "[readchild(%s, %d, %d) write done]",
 			 child->c_name, child->c_pid, child->c_readfd);
 	}
Index: src/client.c
===================================================================
RCS file: /local/cvsfiles/kerberos/src/appl/rdist/src/client.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- client.c	1995/03/15 22:10:24	1.2
+++ client.c	1995/03/24 22:44:37	1.3
@@ -429,12 +429,18 @@
 			 * this situation gracefully.
 			 */
 		}
-		if (write(rem, buf, amt) == -1) {
-			error("%s: Error writing to client: %s", 
-			      target, SYSERR);
-			err();
-			++goterr;
-			break;
+		{
+			int ramt, wamt=amt, woff=0;
+			while((ramt=write(rem,buf+woff,wamt)) > 0) {
+				woff += ramt; wamt -= ramt;
+			}
+			if (ramt < 0) {
+				error("%s: Error writing to client: %s", 
+				      target, SYSERR);
+				err();
+				++goterr;
+				break;
+			}
 		}
 		(void) alarm(0);
 	}
Index: src/common.c
===================================================================
RCS file: /local/cvsfiles/kerberos/src/appl/rdist/src/common.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- common.c	1995/03/15 22:10:26	1.3
+++ common.c	1995/03/24 22:44:40	1.4
@@ -268,7 +268,13 @@
 		 (cmd == C_NONE) ? len-1 : len-2,
 		 (cmd == C_NONE) ? msg : msg + 1);
 
-	return(!(write(rem, msg, len) == len));
+	{
+		int ramt, wamt=len, woff=0;
+		while((ramt = write(rem,msg+woff,wamt)) > 0) {
+			woff += ramt; wamt -= ramt;
+		}
+		return ramt<0;
+	}
 }
 
 /*


home help back first fref pref prev next nref lref last post