From: Paul Gofman pgofman@codeweavers.com
--- dlls/ws2_32/tests/sock.c | 12 ++++++++++++ server/sock.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index d37c25f9225..b0287fdd004 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -3115,13 +3115,19 @@ struct send_udp_thread_param static DWORD WINAPI send_udp_thread( void *param ) { struct send_udp_thread_param *p = param; + static const TIMEVAL timeout_zero = {0}; static char buf[256]; + fd_set writefds; unsigned int i; int ret;
WaitForSingleObject( p->start_event, INFINITE ); for (i = 0; i < 256; ++i) { + FD_ZERO(&writefds); + FD_SET(p->sock, &writefds); + ret = select( 1, NULL, &writefds, NULL, &timeout_zero ); + ok( ret == 1, "got %d, i %u.\n", ret, i ); ret = send( p->sock, buf, sizeof(buf), 0 ); ok( ret == sizeof(buf), "got %d, error %u, i %u.\n", ret, WSAGetLastError(), i ); } @@ -3135,6 +3141,7 @@ static void test_UDP(void) possible that this test fails due to dropped packets. */
/* peer 0 receives data from all other peers */ + static const TIMEVAL timeout_zero = {0}; struct sock_info peer[NUM_UDP_PEERS]; char buf[16]; int ss, i, n_recv, n_sent, ret; @@ -3142,6 +3149,7 @@ static void test_UDP(void) int sock; struct send_udp_thread_param udp_thread_param; HANDLE thread; + fd_set writefds;
memset (buf,0,sizeof(buf)); @@ -3211,6 +3219,10 @@ static void test_UDP(void) { ret = send( sock, buf, sizeof(buf), 0 ); ok( ret == sizeof(buf), "got %d, error %u, i %u.\n", ret, WSAGetLastError(), i ); + FD_ZERO(&writefds); + FD_SET(sock, &writefds); + ret = select( 1, NULL, &writefds, NULL, &timeout_zero ); + ok( ret == 1, "got %d, i %u.\n", ret, i ); } WaitForSingleObject( thread, INFINITE ); CloseHandle( thread ); diff --git a/server/sock.c b/server/sock.c index a884179c604..3ad1ce39194 100644 --- a/server/sock.c +++ b/server/sock.c @@ -1231,7 +1231,7 @@ static int sock_dispatch_asyncs( struct sock *sock, int event, int error ) event &= ~(POLLIN | POLLPRI); }
- if ((event & POLLOUT) && async_queued( &sock->write_q )) + if ((event & POLLOUT) && async_queue_has_waiting_asyncs( &sock->write_q )) { if (async_waiting( &sock->write_q )) {