diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 23 |
2 files changed, 18 insertions, 10 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4a16d36ab..b731ef181 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,10 @@ 2009-07-06 Corinna Vinschen <corinna@vinschen.de> + * fhandler_socket.cc (fhandler_socket::recv_internal): Convert wsabuf + and wsacnt to references. Fix handling of WSAEMSGSIZE. + +2009-07-06 Corinna Vinschen <corinna@vinschen.de> + * cygtls.h (struct _local_storage): Add thread storage pointers for memory used by socket select functions. Combine them into a single struct select. diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index ea057d699..bd6a2fb31 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -1309,8 +1309,8 @@ fhandler_socket::recv_internal (LPWSAMSG wsamsg) ssize_t res = 0; DWORD ret = 0, wret; int evt_mask = FD_READ | ((wsamsg->dwFlags & MSG_OOB) ? FD_OOB : 0); - LPWSABUF wsabuf = wsamsg->lpBuffers; - ULONG wsacnt = wsamsg->dwBufferCount; + LPWSABUF &wsabuf = wsamsg->lpBuffers; + ULONG &wsacnt = wsamsg->dwBufferCount; bool use_recvmsg = false; static NO_COPY LPFN_WSARECVMSG WSARecvMsg; @@ -1383,20 +1383,23 @@ fhandler_socket::recv_internal (LPWSAMSG wsamsg) break; } - if (!ret && res == SOCKET_ERROR) + if (res) { /* According to SUSv3, errno isn't set in that case and no error condition is returned. */ if (WSAGetLastError () == WSAEMSGSIZE) - return ret; + return ret + wret; - /* ESHUTDOWN isn't defined for recv in SUSv3. Simply EOF is returned - in this case. */ - if (WSAGetLastError () == WSAESHUTDOWN) - return 0; + if (!ret) + { + /* ESHUTDOWN isn't defined for recv in SUSv3. Simply EOF is returned + in this case. */ + if (WSAGetLastError () == WSAESHUTDOWN) + return 0; - set_winsock_errno (); - return SOCKET_ERROR; + set_winsock_errno (); + return SOCKET_ERROR; + } } return ret; |