Jacek Caban : ws2_32: Call get_rcvsnd_timeo directly.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Apr 28 09:10:38 CDT 2015
Module: wine
Branch: master
Commit: 6a80fe9e6bdfe28f4600dee41367e95e9e23b7a0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6a80fe9e6bdfe28f4600dee41367e95e9e23b7a0
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Apr 27 16:00:57 2015 +0200
ws2_32: Call get_rcvsnd_timeo directly.
---
dlls/ws2_32/socket.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index d6bfa94..f904252 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1252,29 +1252,31 @@ static char *strdup_lower(const char *str)
/* Utility: get the SO_RCVTIMEO or SO_SNDTIMEO socket option
* from an fd and return the value converted to milli seconds
* or 0 if there is an infinite time out */
-static inline INT64 get_rcvsnd_timeo( int fd, int optname)
+static inline INT64 get_rcvsnd_timeo( int fd, BOOL is_recv)
{
struct timeval tv;
socklen_t len = sizeof(tv);
- int res = getsockopt(fd, SOL_SOCKET, optname, &tv, &len);
- if (res < 0)
- return 0;
- return (UINT64)tv.tv_sec * 1000 + tv.tv_usec / 1000;
-}
+ int optname, res;
-/* macro wrappers for portability */
+ if (is_recv)
#ifdef SO_RCVTIMEO
-#define GET_RCVTIMEO(fd) get_rcvsnd_timeo( (fd), SO_RCVTIMEO)
+ optname = SO_RCVTIMEO;
#else
-#define GET_RCVTIMEO(fd) (0)
+ return 0;
#endif
-
+ else
#ifdef SO_SNDTIMEO
-#define GET_SNDTIMEO(fd) get_rcvsnd_timeo( (fd), SO_SNDTIMEO)
+ optname = SO_SNDTIMEO;
#else
-#define GET_SNDTIMEO(fd) (0)
+ return 0;
#endif
+ res = getsockopt(fd, SOL_SOCKET, optname, &tv, &len);
+ if (res < 0)
+ return 0;
+ return (UINT64)tv.tv_sec * 1000 + tv.tv_usec / 1000;
+}
+
/* utility: given an fd, will block until one of the events occurs */
static inline int do_block( int fd, int events, int timeout )
{
@@ -5075,7 +5077,7 @@ static int WS2_sendto( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
{
struct pollfd pfd;
int poll_timeout = -1;
- INT64 timeout = GET_SNDTIMEO(fd);
+ INT64 timeout = get_rcvsnd_timeo(fd, FALSE);
if (timeout)
{
@@ -7131,7 +7133,7 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
{
struct pollfd pfd;
int poll_timeout = -1;
- INT64 timeout = GET_RCVTIMEO(fd);
+ INT64 timeout = get_rcvsnd_timeo(fd, TRUE);
if (timeout)
{
More information about the wine-cvs
mailing list