On Tue, 5 Nov 2002, Christopher Faylor wrote:
> There is a thread in cygwin at cygwin entitled:
>
> "1.3.13-2 & 1.3.14-1 problem on read() from dgram socket"
>
> Is anyone willing to debug the problem and, if it is a cygwin problem,
> provide a fix?
>
> cgf
>
> http://cygwin.com/ml/cygwin/2002-10/msg01974.html
>
It seems that the fromlen in WSARecvFrom must be NULL if from is NULL and
not a pointer to 0.
Actually msg->msg_name is NULL and msg->msg_namelen is 0 which will result
in WSAEFAULT.
Thomas
2002-11-05 Thomas Pfaff <[EMAIL PROTECTED]>
* fhandler_socket.cc (fhandler_socket::recvmsg): If from == NULL
call WSARecvFrom with fromlen = NULL.
--- fhandler_socket.cc.org 2002-10-21 03:03:32.000000000 +0200
+++ fhandler_socket.cc 2002-11-05 10:54:49.000000000 +0100
@@ -734,14 +734,16 @@ fhandler_socket::recvmsg (struct msghdr
struct iovec *const iov = msg->msg_iov;
const int iovcnt = msg->msg_iovlen;
+ struct sockaddr *from = (struct sockaddr *) msg->msg_name;
+ int *fromlen = from ? &msg->msg_namelen : NULL;
+
int res;
if (!winsock2_active)
{
if (iovcnt == 1)
res = recvfrom (iov->iov_base, iov->iov_len, flags,
- (struct sockaddr *) msg->msg_name,
- &msg->msg_namelen);
+ from, fromlen);
else
{
if (tot == -1) // i.e. if not pre-calculated by the caller.
@@ -766,8 +768,7 @@ fhandler_socket::recvmsg (struct msghdr
else
{
res = recvfrom (buf, tot, flags,
- (struct sockaddr *) msg->msg_name,
- &msg->msg_namelen);
+ from, fromlen);
const struct iovec *iovptr = iov;
int nbytes = res;
@@ -805,16 +806,14 @@ fhandler_socket::recvmsg (struct msghdr
if (is_nonblocking ())
res = WSARecvFrom (get_socket (),
wsabuf, iovcnt, &ret, (DWORD *) &flags,
- (struct sockaddr *) msg->msg_name,
- &msg->msg_namelen,
+ from, fromlen,
NULL, NULL);
else
{
wsock_event wsock_evt;
res = WSARecvFrom (get_socket (),
wsabuf, iovcnt, &ret, (DWORD *) &flags,
- (struct sockaddr *) msg->msg_name,
- &msg->msg_namelen,
+ from, fromlen,
wsock_evt.prepare (), NULL);
if (res == SOCKET_ERROR && WSAGetLastError () == WSA_IO_PENDING)