Jacek Caban : ws2_32: Use get_rcvsnd_timeo helper in getsockopt.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Apr 28 09:10:38 CDT 2015


Module: wine
Branch: master
Commit: edb780e87f212a8d4a6528eaea7285c8f8cb3c32
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=edb780e87f212a8d4a6528eaea7285c8f8cb3c32

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Apr 27 16:01:15 2015 +0200

ws2_32: Use get_rcvsnd_timeo helper in getsockopt.

---

 dlls/ws2_32/socket.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index f904252..52b5394 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -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)




More information about the wine-cvs mailing list