From f0f3ea68f3b3e3a7b9e21eee2572a0d69ea4d563 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 3 Feb 2003 15:34:52 +0000 Subject: [PATCH] * fhandler_socket.cc (fhandler_socket::recvfrom): Return buffer length and don't set errno in case of WSAEMSGSIZE error. (fhandler_socket::recvmsg): Ditto. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/fhandler_socket.cc | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index d78542e95..884e169c7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2003-02-03 Corinna Vinschen + + * fhandler_socket.cc (fhandler_socket::recvfrom): Return buffer + length and don't set errno in case of WSAEMSGSIZE error. + (fhandler_socket::recvmsg): Ditto. + 2003-02-01 Christopher Faylor * grp.cc (getgrent32): Only refresh group entries when at beginning. diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index a3cbdd738..0e10ad5c6 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -711,6 +711,11 @@ fhandler_socket::recvfrom (void *ptr, size_t len, int flags, if (res == SOCKET_ERROR) { + /* According to SUSv3, errno isn't set in that case and no error + condition is returned. */ + if (WSAGetLastError () == WSAEMSGSIZE) + return len; + res = -1; set_winsock_errno (); } @@ -789,6 +794,7 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot) else { WSABUF wsabuf[iovcnt]; + unsigned long len = 0L; { const struct iovec *iovptr = iov + iovcnt; @@ -797,7 +803,7 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot) { iovptr -= 1; wsaptr -= 1; - wsaptr->len = iovptr->iov_len; + len += wsaptr->len = iovptr->iov_len; wsaptr->buf = (char *) iovptr->iov_base; } while (wsaptr != wsabuf); @@ -824,6 +830,11 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot) if (res == SOCKET_ERROR) { + /* According to SUSv3, errno isn't set in that case and no error + condition is returned. */ + if (WSAGetLastError () == WSAEMSGSIZE) + return len; + res = -1; set_winsock_errno (); }