Commit 9277fcfd authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

ntdll: Fix possible race-condition in iocp poller code.

parent 3a72922e
...@@ -235,12 +235,14 @@ NTSTATUS WINAPI RtlQueueWorkItem(PRTL_WORK_ITEM_ROUTINE Function, PVOID Context, ...@@ -235,12 +235,14 @@ NTSTATUS WINAPI RtlQueueWorkItem(PRTL_WORK_ITEM_ROUTINE Function, PVOID Context,
*/ */
static DWORD CALLBACK iocp_poller(LPVOID Arg) static DWORD CALLBACK iocp_poller(LPVOID Arg)
{ {
HANDLE cport = Arg;
while( TRUE ) while( TRUE )
{ {
PRTL_OVERLAPPED_COMPLETION_ROUTINE callback; PRTL_OVERLAPPED_COMPLETION_ROUTINE callback;
LPVOID overlapped; LPVOID overlapped;
IO_STATUS_BLOCK iosb; IO_STATUS_BLOCK iosb;
NTSTATUS res = NtRemoveIoCompletion( compl_port, (PULONG_PTR)&callback, (PULONG_PTR)&overlapped, &iosb, NULL ); NTSTATUS res = NtRemoveIoCompletion( cport, (PULONG_PTR)&callback, (PULONG_PTR)&overlapped, &iosb, NULL );
if (res) if (res)
{ {
ERR("NtRemoveIoCompletion failed: 0x%x\n", res); ERR("NtRemoveIoCompletion failed: 0x%x\n", res);
...@@ -297,7 +299,7 @@ NTSTATUS WINAPI RtlSetIoCompletionCallback(HANDLE FileHandle, PRTL_OVERLAPPED_CO ...@@ -297,7 +299,7 @@ NTSTATUS WINAPI RtlSetIoCompletionCallback(HANDLE FileHandle, PRTL_OVERLAPPED_CO
if (!res) if (!res)
{ {
/* FIXME native can start additional threads in case of e.g. hung callback function. */ /* FIXME native can start additional threads in case of e.g. hung callback function. */
res = RtlQueueWorkItem( iocp_poller, NULL, WT_EXECUTEDEFAULT ); res = RtlQueueWorkItem( iocp_poller, cport, WT_EXECUTEDEFAULT );
if (!res) if (!res)
compl_port = cport; compl_port = cport;
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment