* fhandler_socket.cc (fhandler_socket::recv_internal): Convert wsabuf

and wsacnt to references.  Fix handling of WSAEMSGSIZE.
This commit is contained in:
Corinna Vinschen 2009-07-06 20:30:34 +00:00
parent 394660ec2f
commit 58fc288ada
2 changed files with 18 additions and 10 deletions

View File

@ -1,3 +1,8 @@
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> 2009-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h (struct _local_storage): Add thread storage pointers for * cygtls.h (struct _local_storage): Add thread storage pointers for

View File

@ -1309,8 +1309,8 @@ fhandler_socket::recv_internal (LPWSAMSG wsamsg)
ssize_t res = 0; ssize_t res = 0;
DWORD ret = 0, wret; DWORD ret = 0, wret;
int evt_mask = FD_READ | ((wsamsg->dwFlags & MSG_OOB) ? FD_OOB : 0); int evt_mask = FD_READ | ((wsamsg->dwFlags & MSG_OOB) ? FD_OOB : 0);
LPWSABUF wsabuf = wsamsg->lpBuffers; LPWSABUF &wsabuf = wsamsg->lpBuffers;
ULONG wsacnt = wsamsg->dwBufferCount; ULONG &wsacnt = wsamsg->dwBufferCount;
bool use_recvmsg = false; bool use_recvmsg = false;
static NO_COPY LPFN_WSARECVMSG WSARecvMsg; static NO_COPY LPFN_WSARECVMSG WSARecvMsg;
@ -1383,20 +1383,23 @@ fhandler_socket::recv_internal (LPWSAMSG wsamsg)
break; break;
} }
if (!ret && res == SOCKET_ERROR) if (res)
{ {
/* According to SUSv3, errno isn't set in that case and no error /* According to SUSv3, errno isn't set in that case and no error
condition is returned. */ condition is returned. */
if (WSAGetLastError () == WSAEMSGSIZE) if (WSAGetLastError () == WSAEMSGSIZE)
return ret; return ret + wret;
/* ESHUTDOWN isn't defined for recv in SUSv3. Simply EOF is returned if (!ret)
in this case. */ {
if (WSAGetLastError () == WSAESHUTDOWN) /* ESHUTDOWN isn't defined for recv in SUSv3. Simply EOF is returned
return 0; in this case. */
if (WSAGetLastError () == WSAESHUTDOWN)
return 0;
set_winsock_errno (); set_winsock_errno ();
return SOCKET_ERROR; return SOCKET_ERROR;
}
} }
return ret; return ret;