Francois Gouget : ws2_32/tests: Fix a race in sock.c:test_write_events().

Alexandre Julliard julliard at winehq.org
Fri Sep 12 07:01:19 CDT 2008


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

Author: Francois Gouget <fgouget at free.fr>
Date:   Thu Sep 11 16:53:43 2008 +0200

ws2_32/tests: Fix a race in sock.c:test_write_events().

Stop draining the socket to make sure we will be able to fill the send 
buffer and trigger a short write.

---

 dlls/ws2_32/tests/sock.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 715516d..ceb9281 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -2020,6 +2020,7 @@ static void test_ioctlsocket(void)
     }
 }
 
+static int drain_pause=0;
 static DWORD WINAPI drain_socket_thread(LPVOID arg)
 {
     char buffer[1024];
@@ -2036,6 +2037,8 @@ static DWORD WINAPI drain_socket_thread(LPVOID arg)
                 FD_ZERO(&readset);
                 FD_SET(sock, &readset);
                 select(0, &readset, NULL, NULL, NULL);
+                while (drain_pause)
+                    Sleep(100);
             }
             else
                 break;
@@ -2188,13 +2191,17 @@ static void test_write_events(void)
         goto end;
     }
 
-    /* Now if we send a tonne of data, the socket send buffer will only take some of it,
-       and we will get a short write, which will trigger another FD_WRITE event
-       as soon as data is sent and more space becomes available, but not any earlier. */
+    /* Now if we send a ton of data and the 'server' does not drain it fast
+     * enough (set drain_pause to be sure), the socket send buffer will only
+     * take some of it, and we will get a short write. This will trigger
+     * another FD_WRITE event as soon as data is sent and more space becomes
+     * available, but not any earlier. */
+    drain_pause=1;
     do
     {
         ret = send(src, buffer, bufferSize, 0);
     } while (ret == bufferSize);
+    drain_pause=0;
     if (ret >= 0 || WSAGetLastError() == WSAEWOULDBLOCK)
     {
         dwRet = WaitForSingleObject(hEvent, 5000);




More information about the wine-cvs mailing list