]> sourceware.org Git - newlib-cygwin.git/commitdiff
* net.cc (cygwin_recvfrom): Don't shortcircuit if len == 0. Add comment
authorCorinna Vinschen <corinna@vinschen.de>
Mon, 21 May 2012 14:56:02 +0000 (14:56 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Mon, 21 May 2012 14:56:02 +0000 (14:56 +0000)
to explain why.
(cygwin_recv): Ditto.
(cygwin_recvmsg): Ditto.

winsup/cygwin/ChangeLog
winsup/cygwin/net.cc

index 30d47c43a363dd856c3e525d3986c7465dc88c76..9e8d5d1af3f33ad2b1d43bd2d9a45f77f250c48e 100644 (file)
@@ -1,3 +1,10 @@
+2012-05-21  Corinna Vinschen  <corinna@vinschen.de>
+
+       * net.cc (cygwin_recvfrom): Don't shortcircuit if len == 0.  Add comment
+       to explain why.
+       (cygwin_recv): Ditto.
+       (cygwin_recvmsg): Ditto.
+
 2012-05-21  Corinna Vinschen  <corinna@vinschen.de>
 
        * fhandler_disk_file.cc (path_conv::isgood_inode): Rearrange, take
index a0a83b55ab5772de12df503da2624343aa52f5d0..3106a8dafce59bb2bc6c20cf7c481ab04bb9f7b3 100644 (file)
@@ -712,7 +712,11 @@ cygwin_recvfrom (int fd, void *buf, size_t len, int flags,
   myfault efault;
   if (efault.faulted (EFAULT) || !fh)
     res = -1;
-  else if ((res = len) != 0)
+  else
+    /* Originally we shortcircuited here if res == 0.
+       Allow 0 bytes buffer.  This is valid in POSIX and handled in
+       fhandler_socket::recv_internal.  If we shortcircuit, we fail
+       to deliver valid error conditions and peer address. */
     res = fh->recvfrom (buf, len, flags, from, fromlen);
 
   syscall_printf ("%R = recvfrom(%d, %p, %d, %x, %p, %p)",
@@ -1465,7 +1469,11 @@ cygwin_recv (int fd, void *buf, size_t len, int flags)
   myfault efault;
   if (efault.faulted (EFAULT) || !fh)
     res = -1;
-  else if ((res = len) != 0)
+  else
+    /* Originally we shortcircuited here if res == 0.
+       Allow 0 bytes buffer.  This is valid in POSIX and handled in
+       fhandler_socket::recv_internal.  If we shortcircuit, we fail
+       to deliver valid error conditions. */
     res = fh->recvfrom (buf, len, flags, NULL, NULL);
 
   syscall_printf ("%R = recv(%d, %p, %d, %x)", res, fd, buf, len, flags);
@@ -2865,7 +2873,11 @@ cygwin_recvmsg (int fd, struct msghdr *msg, int flags)
   else
     {
       res = check_iovec_for_read (msg->msg_iov, msg->msg_iovlen);
-      if (res > 0)
+      /* Originally we shortcircuited here if res == 0.
+        Allow 0 bytes buffer.  This is valid in POSIX and handled in
+        fhandler_socket::recv_internal.  If we shortcircuit, we fail
+        to deliver valid error conditions and peer address. */
+      if (res >= 0)
        res = fh->recvmsg (msg, flags);
     }
 
This page took 0.039416 seconds and 5 git commands to generate.