Rebase against 7bd852c6ce0299f14fa585c124bae029f0d6d214.

This commit is contained in:
Sebastian Lackner 2015-11-09 17:04:55 +01:00
parent 9d447d1e4b
commit f98e04ebc1
6 changed files with 49 additions and 293 deletions

View File

@ -1,4 +1,4 @@
From 4ecefb9629cb3121da17e7d9573c5134dcdc74c6 Mon Sep 17 00:00:00 2001
From eee7c92a62872ca06bb864674ea73ddab09f362e Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 6 Oct 2014 05:06:06 +0200
Subject: dbghelp: Always check for debug symbols in BINDIR.
@ -9,14 +9,14 @@ Subject: dbghelp: Always check for debug symbols in BINDIR.
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/dbghelp/Makefile.in b/dlls/dbghelp/Makefile.in
index e483693..03248a6 100644
index 86846cb..6b72980 100644
--- a/dlls/dbghelp/Makefile.in
+++ b/dlls/dbghelp/Makefile.in
@@ -1,6 +1,6 @@
MODULE = dbghelp.dll
IMPORTLIB = dbghelp
-EXTRADEFS = -D_IMAGEHLP_SOURCE_ -DDLLPREFIX='"$(DLLPREFIX)"'
+EXTRADEFS = -D_IMAGEHLP_SOURCE_ -DDLLPREFIX='"$(DLLPREFIX)"' -DBINDIR="\"${bindir}\""
-EXTRADEFS = -D_IMAGEHLP_SOURCE_
+EXTRADEFS = -D_IMAGEHLP_SOURCE_ -DBINDIR="\"${bindir}\""
IMPORTS = psapi
DELAYIMPORTS = version
EXTRALIBS = $(Z_LIBS) $(CORESERVICES_LIBS) $(COREFOUNDATION_LIBS)
@ -40,5 +40,5 @@ index b176143..8e22265 100644
load_offset, dyn_addr, elf_info);
}
--
2.4.4
2.6.2

View File

@ -1,4 +1,4 @@
From 1b7d74bd0325ceb988838324875369cdea6b26d9 Mon Sep 17 00:00:00 2001
From ebfd5e2652dba8934354b0c20563cbabc717900b Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Fri, 16 Oct 2015 02:32:58 +0200
Subject: ntdll: Use wrapper functions for syscalls.
@ -14,7 +14,7 @@ Subject: ntdll: Use wrapper functions for syscalls.
dlls/ntdll/ntdll_misc.h | 17 ++++++
dlls/ntdll/om.c | 39 +++++++++-----
dlls/ntdll/process.c | 15 ++++--
dlls/ntdll/reg.c | 60 ++++++++++++++-------
dlls/ntdll/reg.c | 63 ++++++++++++++--------
dlls/ntdll/resource.c | 16 ++++--
dlls/ntdll/sec.c | 9 ++--
dlls/ntdll/signal_arm.c | 3 +-
@ -26,7 +26,7 @@ Subject: ntdll: Use wrapper functions for syscalls.
dlls/ntdll/thread.c | 36 ++++++++-----
dlls/ntdll/time.c | 12 +++--
dlls/ntdll/virtual.c | 48 +++++++++++------
22 files changed, 412 insertions(+), 192 deletions(-)
22 files changed, 414 insertions(+), 193 deletions(-)
diff --git a/dlls/ntdll/atom.c b/dlls/ntdll/atom.c
index 304b7f6..222fde9 100644
@ -950,7 +950,7 @@ index ca9462a..37c08f1 100644
{
NTSTATUS status;
diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c
index c0fc641..6df88c3 100644
index 5248595..11a03cd 100644
--- a/dlls/ntdll/reg.c
+++ b/dlls/ntdll/reg.c
@@ -51,7 +51,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(reg);
@ -1064,6 +1064,16 @@ index c0fc641..6df88c3 100644
NTSTATUS ret;
HANDLE hive;
@@ -636,7 +647,8 @@ NTSTATUS WINAPI NtLoadKey( const OBJECT_ATTRIBUTES *attr, OBJECT_ATTRIBUTES *fil
* NtNotifyChangeMultipleKeys [NTDLL.@]
* ZwNotifyChangeMultipleKeys [NTDLL.@]
*/
-NTSTATUS WINAPI NtNotifyChangeMultipleKeys(
+DEFINE_SYSCALL_ENTRYPOINT( NtNotifyChangeMultipleKeys, 12 );
+NTSTATUS WINAPI SYSCALL(NtNotifyChangeMultipleKeys)(
HANDLE KeyHandle,
ULONG Count,
OBJECT_ATTRIBUTES *SubordinateObjects,
@@ -692,7 +704,8 @@ NTSTATUS WINAPI NtNotifyChangeMultipleKeys(
* NtNotifyChangeKey [NTDLL.@]
* ZwNotifyChangeKey [NTDLL.@]
*/
@ -1073,7 +1083,7 @@ index c0fc641..6df88c3 100644
IN HANDLE KeyHandle,
IN HANDLE Event,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
@@ -691,7 +703,8 @@ NTSTATUS WINAPI NtNotifyChangeKey(
@@ -714,7 +727,8 @@ NTSTATUS WINAPI NtNotifyChangeKey(
* ZwQueryMultipleValueKey
*/
@ -1083,7 +1093,7 @@ index c0fc641..6df88c3 100644
HANDLE KeyHandle,
PKEY_MULTIPLE_VALUE_INFORMATION ListOfValuesToQuery,
ULONG NumberOfItems,
@@ -709,7 +722,8 @@ NTSTATUS WINAPI NtQueryMultipleValueKey(
@@ -732,7 +746,8 @@ NTSTATUS WINAPI NtQueryMultipleValueKey(
* NtReplaceKey [NTDLL.@]
* ZwReplaceKey [NTDLL.@]
*/
@ -1093,7 +1103,7 @@ index c0fc641..6df88c3 100644
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN HANDLE Key,
IN POBJECT_ATTRIBUTES ReplacedObjectAttributes)
@@ -722,7 +736,8 @@ NTSTATUS WINAPI NtReplaceKey(
@@ -745,7 +760,8 @@ NTSTATUS WINAPI NtReplaceKey(
* NtRestoreKey [NTDLL.@]
* ZwRestoreKey [NTDLL.@]
*/
@ -1103,7 +1113,7 @@ index c0fc641..6df88c3 100644
HANDLE KeyHandle,
HANDLE FileHandle,
ULONG RestoreFlags)
@@ -735,7 +750,8 @@ NTSTATUS WINAPI NtRestoreKey(
@@ -758,7 +774,8 @@ NTSTATUS WINAPI NtRestoreKey(
* NtSaveKey [NTDLL.@]
* ZwSaveKey [NTDLL.@]
*/
@ -1113,7 +1123,7 @@ index c0fc641..6df88c3 100644
{
NTSTATUS ret;
@@ -755,7 +771,8 @@ NTSTATUS WINAPI NtSaveKey(IN HANDLE KeyHandle, IN HANDLE FileHandle)
@@ -778,7 +795,8 @@ NTSTATUS WINAPI NtSaveKey(IN HANDLE KeyHandle, IN HANDLE FileHandle)
* NtSetInformationKey [NTDLL.@]
* ZwSetInformationKey [NTDLL.@]
*/
@ -1123,7 +1133,7 @@ index c0fc641..6df88c3 100644
IN HANDLE KeyHandle,
IN const int KeyInformationClass,
IN PVOID KeyInformation,
@@ -775,7 +792,8 @@ NTSTATUS WINAPI NtSetInformationKey(
@@ -798,7 +816,8 @@ NTSTATUS WINAPI NtSetInformationKey(
* win95 does not care about count for REG_SZ and finds out the len by itself (js)
* NT does definitely care (aj)
*/
@ -1133,7 +1143,7 @@ index c0fc641..6df88c3 100644
ULONG type, const void *data, ULONG count )
{
NTSTATUS ret;
@@ -814,7 +832,8 @@ NTSTATUS WINAPI RtlpNtSetValueKey( HANDLE hkey, ULONG type, const void *data,
@@ -837,7 +856,8 @@ NTSTATUS WINAPI RtlpNtSetValueKey( HANDLE hkey, ULONG type, const void *data,
* NtUnloadKey [NTDLL.@]
* ZwUnloadKey [NTDLL.@]
*/
@ -1143,7 +1153,7 @@ index c0fc641..6df88c3 100644
{
NTSTATUS ret;
@@ -1421,7 +1440,8 @@ NTSTATUS WINAPI RtlWriteRegistryValue( ULONG RelativeTo, PCWSTR path, PCWSTR nam
@@ -1444,7 +1464,8 @@ NTSTATUS WINAPI RtlWriteRegistryValue( ULONG RelativeTo, PCWSTR path, PCWSTR nam
* unless there is some app which explicitly depends on that, there is
* no good reason to reproduce that.
*/

View File

@ -1,4 +1,4 @@
From f98d759df530437f92f75be55917bec366ece883 Mon Sep 17 00:00:00 2001
From 0026d5f6d3bd8fead6081e21d3a5f45f415d31df Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Fri, 16 Oct 2015 05:31:11 +0200
Subject: ntdll: Syscalls should not call Nt*Ex thunk wrappers.
@ -6,10 +6,11 @@ Subject: ntdll: Syscalls should not call Nt*Ex thunk wrappers.
---
dlls/ntdll/nt.c | 4 ++--
dlls/ntdll/ntdll_misc.h | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
dlls/ntdll/reg.c | 2 +-
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index e48e6d4..ace7196 100644
index 19d5b6e..a0d8909 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -124,7 +124,7 @@ NTSTATUS WINAPI SYSCALL(NtOpenProcessToken)(
@ -31,10 +32,10 @@ index e48e6d4..ace7196 100644
/******************************************************************************
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index b63005e..11099c5 100644
index 5566080..ee94382 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -277,6 +277,8 @@ DECLARE_SYSCALL_ENTRYPOINT( NtFlushVirtualMemory );
@@ -280,6 +280,8 @@ DECLARE_SYSCALL_ENTRYPOINT( NtFlushVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtFreeVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtLockVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtMapViewOfSection );
@ -43,6 +44,19 @@ index b63005e..11099c5 100644
DECLARE_SYSCALL_ENTRYPOINT( NtProtectVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtQueryVirtualMemory );
DECLARE_SYSCALL_ENTRYPOINT( NtUnlockVirtualMemory );
diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c
index 11a03cd..cb5b514 100644
--- a/dlls/ntdll/reg.c
+++ b/dlls/ntdll/reg.c
@@ -717,7 +717,7 @@ NTSTATUS WINAPI SYSCALL(NtNotifyChangeKey)(
IN ULONG Length,
IN BOOLEAN Asynchronous)
{
- return NtNotifyChangeMultipleKeys(KeyHandle, 0, NULL, Event, ApcRoutine, ApcContext,
+ return SYSCALL(NtNotifyChangeMultipleKeys)(KeyHandle, 0, NULL, Event, ApcRoutine, ApcContext,
IoStatusBlock, CompletionFilter, WatchSubtree,
ChangeBuffer, Length, Asynchronous);
}
--
2.6.1
2.6.2

View File

@ -52,7 +52,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "a0d0d0dd0a5b4a500ab8d37cc6e687a202997d56"
echo "7bd852c6ce0299f14fa585c124bae029f0d6d214"
}
# Show version information
@ -6456,11 +6456,9 @@ fi
# |
if test "$enable_ws2_32_WSAPoll" -eq 1; then
patch_apply ws2_32-WSAPoll/0001-include-Remove-check-for-__WINE_WNE_PORT_H-in-winsoc.patch
patch_apply ws2_32-WSAPoll/0002-ws2_32-tests-Add-WSAPoll-tests.patch
patch_apply ws2_32-WSAPoll/0003-ws2_32-Add-WSAPoll-implementation.patch
patch_apply ws2_32-WSAPoll/0002-ws2_32-Add-WSAPoll-implementation.patch
(
echo '+ { "Sebastian Lackner", "include: Remove check for __WINE_WNE_PORT_H in winsock2.h.", 1 },';
echo '+ { "Bruno Jesus", "ws2_32/tests: Add WSAPoll() tests.", 1 },';
echo '+ { "Bruno Jesus", "ws2_32: Add WSAPoll() implementation.", 1 },';
) >> "$patchlist"
fi

View File

@ -1,266 +0,0 @@
From 47bf6e8f213c1a1d023d160a829e390705db95e0 Mon Sep 17 00:00:00 2001
From: Bruno Jesus <00cpxxx@gmail.com>
Date: Fri, 22 May 2015 22:43:00 -0300
Subject: ws2_32/tests: Add WSAPoll() tests
---
dlls/ws2_32/tests/sock.c | 222 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 222 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 7fbd67d..7901bda 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -74,6 +74,7 @@ static int (WINAPI *pWSALookupServiceEnd)(HANDLE);
static int (WINAPI *pWSALookupServiceNextW)(HANDLE,DWORD,LPDWORD,LPWSAQUERYSETW);
static int (WINAPI *pWSAEnumNameSpaceProvidersA)(LPDWORD,LPWSANAMESPACE_INFOA);
static int (WINAPI *pWSAEnumNameSpaceProvidersW)(LPDWORD,LPWSANAMESPACE_INFOW);
+static int (WINAPI *pWSAPoll)(WSAPOLLFD *,ULONG,INT);
/**************** Structs and typedefs ***************/
@@ -1169,6 +1170,7 @@ static void Init (void)
pWSALookupServiceNextW = (void *)GetProcAddress(hws2_32, "WSALookupServiceNextW");
pWSAEnumNameSpaceProvidersA = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersA");
pWSAEnumNameSpaceProvidersW = (void *)GetProcAddress(hws2_32, "WSAEnumNameSpaceProvidersW");
+ pWSAPoll = (void *)GetProcAddress(hws2_32, "WSAPoll");
ok ( WSAStartup ( ver, &data ) == 0, "WSAStartup failed\n" );
tls = TlsAlloc();
@@ -6330,6 +6332,225 @@ end:
WSACloseEvent(ov.hEvent);
}
+#define POLL_CLEAR() ix = 0
+#define POLL_SET(s, ev) {fds[ix].fd = s; fds[ix++].events = ev;}
+#define POLL_ISSET(s, rev) poll_isset(fds, ix, s, rev)
+static BOOL poll_isset(WSAPOLLFD *fds, int max, SOCKET s, int rev)
+{
+ int k;
+ for (k = 0; k < max; k++)
+ if (fds[k].fd == s && (fds[k].revents == rev)) return TRUE;
+ return FALSE;
+}
+
+static void test_WSAPoll(void)
+{
+ int ix, ret, err, poll_timeout;
+ SOCKET fdListen, fdRead, fdWrite;
+ struct sockaddr_in address;
+ socklen_t len;
+ static char tmp_buf[1024];
+ WSAPOLLFD fds[16];
+ HANDLE thread_handle;
+ DWORD id;
+
+ if (!pWSAPoll) /* >= Vista */
+ {
+ skip("WSAPoll is unsupported, some tests will be skipped.\n");
+ return;
+ }
+
+ /* Invalid parameters test */
+ SetLastError(0xdeadbeef);
+ ret = pWSAPoll(NULL, 0, 0);
+ err = GetLastError();
+ ok(ret == SOCKET_ERROR, "expected -1, got %d\n", ret);
+ ok(err == WSAEINVAL, "expected 10022, got %d\n", err);
+ SetLastError(0xdeadbeef);
+ ret = pWSAPoll(NULL, 1, 0);
+ err = GetLastError();
+ ok(ret == SOCKET_ERROR, "expected -1, got %d\n", ret);
+ ok(err == WSAEFAULT, "expected 10014, got %d\n", err);
+ SetLastError(0xdeadbeef);
+ ret = pWSAPoll(NULL, 0, 1);
+ err = GetLastError();
+ ok(ret == SOCKET_ERROR, "expected -1, got %d\n", ret);
+ ok(err == WSAEINVAL, "expected 10022, got %d\n", err);
+ SetLastError(0xdeadbeef);
+ ret = pWSAPoll(NULL, 1, 1);
+ err = GetLastError();
+ ok(ret == SOCKET_ERROR, "expected -1, got %d\n", ret);
+ ok(err == WSAEFAULT, "expected 10014, got %d\n", err);
+
+ /* WSAPoll() tries to mime the unix poll() call. The following tests do:
+ * - check if a connection attempt ended with success or error;
+ * - check if a pending connection is waiting for acceptance;
+ * - check for data to read, availability for write and OOB data
+ */
+ memset(&address, 0, sizeof(address));
+ address.sin_addr.s_addr = inet_addr("127.0.0.1");
+ address.sin_family = AF_INET;
+ len = sizeof(address);
+ fdListen = setup_server_socket(&address, &len);
+ poll_timeout = 100;
+
+ /* When no events are pending poll returns 0 with no error */
+ POLL_CLEAR();
+ POLL_SET(fdListen, POLLIN);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 0, "expected 0, got %d\n", ret);
+
+ /* Test listening socket connection attempt notifications */
+ fdWrite = setup_connector_socket(&address, len, TRUE);
+ POLL_CLEAR();
+ POLL_SET(fdListen, POLLIN | POLLOUT);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(POLL_ISSET(fdListen, POLLRDNORM), "fdListen socket events incorrect\n");
+ len = sizeof(address);
+ fdRead = accept(fdListen, (struct sockaddr*) &address, &len);
+ ok(fdRead != INVALID_SOCKET, "expected a valid socket\n");
+
+ /* Test client side connection attempt notifications */
+ POLL_CLEAR();
+ POLL_SET(fdListen, POLLIN | POLLOUT);
+ POLL_SET(fdRead, POLLIN | POLLOUT);
+ POLL_SET(fdWrite, POLLIN | POLLOUT);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 2, "expected 2, got %d\n", ret);
+ ok(POLL_ISSET(fdWrite, POLLWRNORM), "fdWrite socket events incorrect\n");
+ ok(POLL_ISSET(fdRead, POLLWRNORM), "fdRead socket events incorrect\n");
+ len = sizeof(id);
+ id = 0xdeadbeef;
+ ok(!getsockopt(fdWrite, SOL_SOCKET, SO_ERROR, (char*)&id, &len),
+ "getsockopt failed with %d\n",WSAGetLastError());
+ ok(id == 0, "expected 0, got %d\n", id);
+
+ /* Test data receiving notifications */
+ ret = send(fdWrite, "1234", 4, 0);
+ ok(ret == 4, "expected 4, got %d\n", ret);
+ POLL_CLEAR();
+ POLL_SET(fdListen, POLLIN | POLLOUT);
+ POLL_SET(fdRead, POLLIN);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(POLL_ISSET(fdRead, POLLRDNORM), "fdRead socket events incorrect\n");
+ ret = recv(fdRead, tmp_buf, sizeof(tmp_buf), 0);
+ ok(ret == 4, "expected 4, got %d\n", ret);
+ ok(!strcmp(tmp_buf, "1234"), "data received differs from sent\n");
+
+ /* Test OOB data notifications */
+ ret = send(fdWrite, "A", 1, MSG_OOB);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ POLL_CLEAR();
+ POLL_SET(fdListen, POLLIN | POLLOUT);
+ POLL_SET(fdRead, POLLIN);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(POLL_ISSET(fdRead, POLLRDBAND), "fdRead socket events incorrect\n");
+ tmp_buf[0] = 0xAF;
+ ret = recv(fdRead, tmp_buf, sizeof(tmp_buf), MSG_OOB);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(tmp_buf[0] == 'A', "expected 'A', got 0x%02X\n", tmp_buf[0]);
+
+ /* If the socket is OOBINLINED the notification is like normal data */
+ ret = 1;
+ ret = setsockopt(fdRead, SOL_SOCKET, SO_OOBINLINE, (char*) &ret, sizeof(ret));
+ ok(ret == 0, "expected 0, got %d\n", ret);
+ ret = send(fdWrite, "A", 1, MSG_OOB);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ POLL_CLEAR();
+ POLL_SET(fdListen, POLLIN | POLLOUT);
+ POLL_SET(fdRead, POLLIN | POLLOUT);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ tmp_buf[0] = 0xAF;
+ SetLastError(0xdeadbeef);
+ ret = recv(fdRead, tmp_buf, sizeof(tmp_buf), MSG_OOB);
+ ok(ret == SOCKET_ERROR, "expected -1, got %d\n", ret);
+ ok(GetLastError() == WSAEINVAL, "expected 10022, got %d\n", GetLastError());
+ ret = recv(fdRead, tmp_buf, sizeof(tmp_buf), 0);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(tmp_buf[0] == 'A', "expected 'A', got 0x%02X\n", tmp_buf[0]);
+
+ /* Test connection closed notifications */
+ ret = closesocket(fdRead);
+ ok(ret == 0, "expected 0, got %d\n", ret);
+ POLL_CLEAR();
+ POLL_SET(fdListen, POLLIN | POLLOUT);
+ POLL_SET(fdWrite, POLLIN);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(POLL_ISSET(fdWrite, POLLHUP), "fdWrite socket events incorrect\n");
+ ret = recv(fdWrite, tmp_buf, sizeof(tmp_buf), 0);
+ ok(ret == 0, "expected 0, got %d\n", ret);
+
+ /* When a connection is attempted to a non-listening socket due to a bug
+ * in the MS code it will never be notified. This is a long standing issue
+ * that will never be fixed for compatibility reasons so we have to deal
+ * with it manually. */
+ ret = closesocket(fdWrite);
+ ok(ret == 0, "expected 0, got %d\n", ret);
+ ret = closesocket(fdListen);
+ ok(ret == 0, "expected 0, got %d\n", ret);
+ len = sizeof(address);
+ fdWrite = setup_connector_socket(&address, len, TRUE);
+ POLL_CLEAR();
+ POLL_SET(fdWrite, POLLIN | POLLOUT);
+ poll_timeout = 2000;
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 0, "expected 0, got %d\n", ret);
+ len = sizeof(id);
+ id = 0xdeadbeef;
+ ok(!getsockopt(fdWrite, SOL_SOCKET, SO_ERROR, (char*)&id, &len),
+ "getsockopt failed with %d\n", WSAGetLastError());
+ ok(id == WSAECONNREFUSED, "expected 10061, got %d\n", id);
+ closesocket(fdWrite);
+
+ /* Try poll() on a closed socket after connection */
+ ok(!tcp_socketpair(&fdRead, &fdWrite), "creating socket pair failed\n");
+ closesocket(fdRead);
+ POLL_CLEAR();
+ POLL_SET(fdWrite, POLLIN | POLLOUT);
+ POLL_SET(fdRead, POLLIN | POLLOUT);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(POLL_ISSET(fdRead, POLLNVAL), "fdRead socket events incorrect\n");
+ POLL_CLEAR();
+ POLL_SET(fdWrite, POLLIN | POLLOUT);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(POLL_ISSET(fdWrite, POLLWRNORM | POLLHUP) || broken(POLL_ISSET(fdWrite, POLLWRNORM)) /* <= 2008 */,
+ "fdWrite socket events incorrect\n");
+ closesocket(fdWrite);
+
+ /* Close the socket currently being polled in a thread */
+ ok(!tcp_socketpair(&fdRead, &fdWrite), "creating socket pair failed\n");
+ thread_handle = CreateThread(NULL, 0, SelectCloseThread, &fdWrite, 0, &id);
+ ok(thread_handle != NULL, "CreateThread failed unexpectedly: %d\n", GetLastError());
+ POLL_CLEAR();
+ POLL_SET(fdWrite, POLLIN | POLLOUT);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(POLL_ISSET(fdWrite, POLLWRNORM), "fdWrite socket events incorrect\n");
+ WaitForSingleObject (thread_handle, 1000);
+ closesocket(fdRead);
+ /* test again with less flags - behavior changes */
+ ok(!tcp_socketpair(&fdRead, &fdWrite), "creating socket pair failed\n");
+ thread_handle = CreateThread(NULL, 0, SelectCloseThread, &fdWrite, 0, &id);
+ ok(thread_handle != NULL, "CreateThread failed unexpectedly: %d\n", GetLastError());
+ POLL_CLEAR();
+ POLL_SET(fdWrite, POLLIN);
+ ret = pWSAPoll(fds, ix, poll_timeout);
+ ok(ret == 1, "expected 1, got %d\n", ret);
+ ok(POLL_ISSET(fdWrite, POLLNVAL), "fdWrite socket events incorrect\n");
+ WaitForSingleObject (thread_handle, 1000);
+ closesocket(fdRead);
+}
+#undef POLL_SET
+#undef POLL_ISSET
+#undef POLL_CLEAR
+
static void test_GetAddrInfoW(void)
{
static const WCHAR port[] = {'8','0',0};
@@ -9048,6 +9269,7 @@ START_TEST( sock )
test_WSASendMsg();
test_WSASendTo();
test_WSARecv();
+ test_WSAPoll();
test_events(0);
test_events(1);
--
2.6.1