Bug 1331810: enable sending of 0 size UDP packets in NSPR. r?ted draft
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Wed, 18 Jan 2017 11:50:12 -0800
changeset 463259 05e946a1ad2ddb52d2f9e00ec16fd4251c80ca75
parent 463197 b3774461acc6bee2216c5f57e167f9e5795fb09d
child 542621 c329b354fe79eea50fafc64dce3b4b70915aec29
push id42005
push userdrno@ohlmeier.org
push dateWed, 18 Jan 2017 19:50:37 +0000
reviewersted
bugs1331810
milestone53.0a1
Bug 1331810: enable sending of 0 size UDP packets in NSPR. r?ted MozReview-Commit-ID: 5Yvk7stHwdn
nsprpub/pr/src/io/prsocket.c
nsprpub/pr/src/md/windows/w95sock.c
--- a/nsprpub/pr/src/io/prsocket.c
+++ b/nsprpub/pr/src/io/prsocket.c
@@ -746,30 +746,30 @@ static PRInt32 PR_CALLBACK SocketSendTo(
 	if (addr->raw.family == PR_AF_INET6) {
 		addrCopy = *addr;
 		addrCopy.raw.family = AF_INET6;
 		addrp = &addrCopy;
 	}
 #endif
 
 	count = 0;
-	while (amount > 0) {
+	do {
 		temp = _PR_MD_SENDTO(fd, buf, amount, flags,
 		    addrp, PR_NETADDR_SIZE(addr), timeout);
 		if (temp < 0) {
 					count = -1;
 					break;
 				}
 		count += temp;
 		if (fd->secret->nonblocking) {
 			break;
 		}
 		buf = (const void*) ((const char*)buf + temp);
 		amount -= temp;
-	}
+	} while (amount > 0);
 	return count;
 }
 
 static PRInt32 PR_CALLBACK SocketRecvFrom(PRFileDesc *fd, void *buf, PRInt32 amount,
 PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout)
 {
 	PRInt32 rv;
 	PRUint32 al;
--- a/nsprpub/pr/src/md/windows/w95sock.c
+++ b/nsprpub/pr/src/md/windows/w95sock.c
@@ -289,18 +289,17 @@ PRInt32
 PRInt32
 _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
               const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout)
 {
     PROsfd osfd = fd->secret->md.osfd;
     PRInt32 rv, err;
     PRInt32 bytesSent = 0;
 
-    while(bytesSent < amount) 
-    {
+    do {
         while ((rv = sendto( osfd, buf, amount, 0, (struct sockaddr *) addr,
                 addrlen)) == -1) 
         {
             if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) 
                 && (!fd->secret->nonblocking))
             {
                 rv = socket_io_wait(osfd, WRITE_FD, timeout);
                 if ( rv < 0 )
@@ -322,17 +321,17 @@ PRInt32
         if (bytesSent < amount) 
         {
             rv = socket_io_wait(osfd, WRITE_FD, timeout);
             if (rv < 0) 
             {
                 return -1;
             }
         }
-    }
+    } while(bytesSent < amount);
     return bytesSent;
 }
 
 PRInt32
 _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
                 PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout)
 {
     PROsfd osfd = fd->secret->md.osfd;