$NetBSD: patch-de,v 1.1 1999/04/28 23:57:04 rvb Exp $

diff -u /usr/pkgsrc/net/coda-5.2.2/coda-src/rpc2/sftp3.c ./coda-src/rpc2/sftp3.c
--- /usr/pkgsrc/net/coda-5.2.2/coda-src/rpc2/sftp3.c	Mon Apr  5 18:00:41 1999
+++ ./coda-src/rpc2/sftp3.c	Mon Apr 26 14:05:08 1999
@@ -320,21 +320,22 @@
 	return(0);
     }
 
+#if 0
     /* Harvest the RTT observation if this is the first packet. (And try to
      * get an estimate of the amount of bytes transferred on this roundtrip) */
     if (pBuff->Header.SEFlags & SFTP_FIRST) 
 	sftp_UpdateRTT(pBuff, sEntry, pBuff->Prefix.LengthOfPacket +    /*data*/
 				      sizeof(struct RPC2_PacketHeader));/*ack?*/
+#endif
 	    
-#if 0 /* this test is bogus and makes us return bad timestamps when
-	 packets are dropped. --JH */
-    /* We are seeing this packet for the first time */
+#if 1
     if (pBuff->Header.SeqNumber == sEntry->RecvLastContig+1) 
-	/* This packet advances the left edge of the window. 
-	   Save the timestamp to echo in the next ack */
+	/* This packet advances the left edge of the window. Save the
+	 * timestamp to echo in the next ack */
 	sEntry->TimeEcho = pBuff->Header.TimeStamp;
 #else
-    /* We are seeing this packet for the first time */
+    /* Keep track of the highest seen timestamp value, we use this when
+     * replying to the other side */
     if (sEntry->TimeEcho < pBuff->Header.TimeStamp)
 	sEntry->TimeEcho = pBuff->Header.TimeStamp;
 #endif
@@ -358,13 +359,15 @@
 		 sEntry->RecvLastContig + i <= sEntry->RecvMostRecent; i++) 
 		if (TESTBIT(sEntry->RecvTheseBits, i)) {
 		    pb = sEntry->ThesePackets[PBUFF((sEntry->RecvLastContig + i))];
-		    if (pb->Header.TimeEcho >= pBuff->Header.TimeEcho && 
-			!(pb->Header.SEFlags & SFTP_COUNTED)) {
+		    if (pb->Header.TimeEcho >= pBuff->Header.TimeEcho) {
+			//&& !(pb->Header.SEFlags & SFTP_COUNTED)) {
 			dataThisRound += pb->Prefix.LengthOfPacket;
 			pb->Header.SEFlags |= SFTP_COUNTED;
 		    }
 		}
 	    if (dataThisRound)
+		/* XXX The dataThisRound value is NOT equal to the data that
+		 * was actually sent if we sent duplicate packets! -JH */
 		sftp_UpdateBW(pBuff, dataThisRound, sEntry);
 
 	    /* recalculate the retry timeout */
@@ -582,8 +585,11 @@
 	for (i = sEntry->SendLastContig+1; i <= pBuff->Header.GotEmAll; i++) 
 	    {
 	    pb = sEntry->ThesePackets[PBUFF(i)];
-	    if (!(ntohl(pb->Header.SEFlags) & SFTP_COUNTED))
-		dataThisRound += ntohl(pb->Header.BodyLength);
+	    /* I had added the following test, but it makes us underestimate
+	     * by a large amount the actual transferred data size (as reported
+	     * to sftp_UpdateBW) -JH */
+	    /* if (!(ntohl(pb->Header.SEFlags) & SFTP_COUNTED)) */
+	    dataThisRound += ntohl(pb->Header.BodyLength);
 	    }
 
 	for (i = 1; i <= sizeof(int)*BITMASKWIDTH; i++)
@@ -599,6 +605,8 @@
 	        }
 
 	if (dataThisRound)
+	    /* XXX This is bogus, the succesfully acked data is NOT equal to
+	     * the data we actually transferred over the wire! -JH */
 	    sftp_UpdateBW(pBuff, dataThisRound, sEntry);
     }
 
