Commit edb780e8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ws2_32: Use get_rcvsnd_timeo helper in getsockopt.

parent 6a80fe9e
...@@ -3619,16 +3619,10 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3619,16 +3619,10 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
} }
return ret ? 0 : SOCKET_ERROR; return ret ? 0 : SOCKET_ERROR;
} }
#ifdef SO_RCVTIMEO
case WS_SO_RCVTIMEO: case WS_SO_RCVTIMEO:
#endif
#ifdef SO_SNDTIMEO
case WS_SO_SNDTIMEO: case WS_SO_SNDTIMEO:
#endif
#if defined(SO_RCVTIMEO) || defined(SO_SNDTIMEO)
{ {
struct timeval tv; INT64 timeout;
socklen_t len = sizeof(struct timeval);
if (!optlen || *optlen < sizeof(int)|| !optval) if (!optlen || *optlen < sizeof(int)|| !optval)
{ {
...@@ -3638,22 +3632,12 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level, ...@@ -3638,22 +3632,12 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
if ( (fd = get_sock_fd( s, 0, NULL )) == -1) if ( (fd = get_sock_fd( s, 0, NULL )) == -1)
return SOCKET_ERROR; return SOCKET_ERROR;
convert_sockopt(&level, &optname); timeout = get_rcvsnd_timeo(fd, optname == WS_SO_RCVTIMEO);
if (getsockopt(fd, level, optname, &tv, &len) != 0 ) *(int *)optval = timeout <= UINT32_MAX ? timeout : UINT32_MAX;
{
SetLastError(wsaErrno());
ret = SOCKET_ERROR;
}
else
{
*(int *)optval = tv.tv_sec * 1000 + tv.tv_usec / 1000;
*optlen = sizeof(int);
}
release_sock_fd( s, fd ); release_sock_fd( s, fd );
return ret; return ret;
} }
#endif
case WS_SO_TYPE: case WS_SO_TYPE:
{ {
if (!optlen || *optlen < sizeof(int) || !optval) if (!optlen || *optlen < sizeof(int) || !optval)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment