ws2_32: Use get_rcvsnd_timeo helper in getsockopt.

This commit is contained in:
Jacek Caban 2015-04-27 16:01:15 +02:00 committed by Alexandre Julliard
parent 6a80fe9e6b
commit edb780e87f
1 changed files with 3 additions and 19 deletions

View File

@ -3619,16 +3619,10 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
}
return ret ? 0 : SOCKET_ERROR;
}
#ifdef SO_RCVTIMEO
case WS_SO_RCVTIMEO:
#endif
#ifdef SO_SNDTIMEO
case WS_SO_SNDTIMEO:
#endif
#if defined(SO_RCVTIMEO) || defined(SO_SNDTIMEO)
{
struct timeval tv;
socklen_t len = sizeof(struct timeval);
INT64 timeout;
if (!optlen || *optlen < sizeof(int)|| !optval)
{
@ -3638,22 +3632,12 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
if ( (fd = get_sock_fd( s, 0, NULL )) == -1)
return SOCKET_ERROR;
convert_sockopt(&level, &optname);
if (getsockopt(fd, level, optname, &tv, &len) != 0 )
{
SetLastError(wsaErrno());
ret = SOCKET_ERROR;
}
else
{
*(int *)optval = tv.tv_sec * 1000 + tv.tv_usec / 1000;
*optlen = sizeof(int);
}
timeout = get_rcvsnd_timeo(fd, optname == WS_SO_RCVTIMEO);
*(int *)optval = timeout <= UINT32_MAX ? timeout : UINT32_MAX;
release_sock_fd( s, fd );
return ret;
}
#endif
case WS_SO_TYPE:
{
if (!optlen || *optlen < sizeof(int) || !optval)