[PATCH] ws2_32: Support indefinite receive timeouts
Jason Edmeades
jason.edmeades at googlemail.com
Thu Feb 11 15:37:42 CST 2010
-------------- next part --------------
From fb93c2125d50d49188e0b7bbd95d08d9e446e669 Mon Sep 17 00:00:00 2001
From: Jason Edmeades <jason.edmeades at googlemail.com>
Date: Thu, 11 Feb 2010 13:32:18 -0800
Subject: [PATCH] ws2_32: Support indefinite receive timeouts
Setting a receive timeout of indefinite wait means setting the socket
option to 0, but the code previously has a minimum value of half a
second. This causes 10060 (timeout) errors in an application I was
debugging.
---
dlls/ws2_32/socket.c | 2 +-
dlls/ws2_32/tests/sock.c | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index c66c853..1af90b1 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3303,7 +3303,7 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
tval.tv_usec = (*(const UINT32*)optval % 1000) * 1000;
tval.tv_sec = *(const UINT32*)optval / 1000;
/* min of 500 milliseconds */
- if (tval.tv_sec == 0 && tval.tv_usec < 500000)
+ if (tval.tv_sec == 0 && tval.tv_usec && tval.tv_usec < 500000)
tval.tv_usec = 500000;
optlen = sizeof(struct timeval);
optval = (char*)&tval;
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index be846fa..5cc5709 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -986,6 +986,15 @@ static void test_set_getsockopt(void)
err = getsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, &size);
ok( !err, "get/setsockopt(SO_RCVTIMEO) failed error: %d\n", WSAGetLastError());
ok( timeout == SOCKTIMEOUT1, "getsockopt(SO_RCVTIMEO) returned wrong value %d\n", timeout);
+
+ timeout = 0;
+ size = sizeof(timeout);
+ err = setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, size);
+ if( !err)
+ err = getsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, &size);
+ ok( !err, "get/setsockopt(SO_RCVTIMEO) failed error: %d\n", WSAGetLastError());
+ ok( timeout == 0, "getsockopt(SO_RCVTIMEO) returned wrong value %d\n", timeout);
+
/* SO_SNDTIMEO */
timeout = SOCKTIMEOUT2; /* 997 seconds. See remark above */
size = sizeof(timeout);
--
1.6.0.4
More information about the wine-patches
mailing list