Bug 1331810: enable sending of 0 size UDP packets in NSPR. r?ted
MozReview-Commit-ID: 5Yvk7stHwdn
--- 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;