Bug 1331810, enable sending of 0 size UDP packets in NSPR. r=ted
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Thu, 16 Mar 2017 14:59:23 +0100
changeset 4712 271a33c4c9a40299f481ec9c151673ae5aa14605
parent 4711 0835554ac65ebbf1875c37454f34f315fbb514a6
child 4713 076df342de923c390e51cd0a9058d8f7cb6ceea1
push id235
push userkaie@kuix.de
push dateThu, 16 Mar 2017 13:58:43 +0000
reviewersted
bugs1331810
Bug 1331810, enable sending of 0 size UDP packets in NSPR. r=ted
pr/src/io/prsocket.c
pr/src/md/windows/w95sock.c
--- a/pr/src/io/prsocket.c
+++ b/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/pr/src/md/windows/w95sock.c
+++ b/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;