Jason Edmeades : ws2_32: Support indefinite receive timeouts.

Alexandre Julliard julliard at winehq.org
Fri Feb 12 10:17:42 CST 2010


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

Author: Jason Edmeades <jason.edmeades at googlemail.com>
Date:   Thu Feb 11 13:32:18 2010 -0800

ws2_32: Support indefinite receive timeouts.

---

 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..5b519b8 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);




More information about the wine-cvs mailing list