Commit Graph

75 Commits

Author SHA1 Message Date
Stefan Dösinger 759e6f1d8d ntdll: Avoid more race conditions in RtlDeregisterWaitEx.
af35aada9b left some issues unfixed.
Instead of running the callback and returning a retval that indicates
the callback is not running, we sometimes wait for it when we are not
supposed to.

Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2018-10-31 19:13:15 +01:00
Stefan Dösinger af35aada9b ntdll: Make RtlDeregisterWaitEx(handle, INVALID_HANDLE_VALUE) thread safe.
Chromium signals the wait semaphore and calls DeregisterWaitEx with
CompletionHandle = INVALID_HANDLE_VALUE in close succession. Sometimes
the worker thread decides to run the callback, but before it sets
CallbackInProgress RtlDeregisterWaitEx decides that the callback is not
running and returns STATUS_SUCCESS. Chromium then releases resources
that the callback needs to run, resulting in random crashes.

Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2017-09-06 20:32:07 +02:00
Bruno Jesus 3b3c0d9e09 ntdll: Use a helper to allocate threadpool workers.
Signed-off-by: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-23 12:16:49 +09:00
Keno Fischer 90173ce448 ntdll: Tolerate null handle in DeregisterWait.
Signed-off-by: Keno Fischer <keno@juliacomputing.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-22 23:05:22 +09:00
Sebastian Lackner a9f648ef69 ntdll: Do not call group cancel callback for finished simple callbacks.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-22 12:51:24 +09:00
Sebastian Lackner be7bcdc0f9 ntdll: Group cancel callbacks should be executed after waiting for pending callbacks.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-22 12:50:50 +09:00
Sebastian Lackner a8830a2478 ntdll: Call group cancel callback with the correct arguments.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-22 12:50:44 +09:00
Sebastian Lackner 53db77b5d7 ntdll: Allow to release threadpool objects while waiting for group.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-22 12:50:33 +09:00
Sebastian Lackner d085042ab9 ntdll: Convert an ERR to a WARN when wait is triggered while destroying threadpool object.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-19 16:15:01 +09:00
Nikolay Sivov 7de025c970 ntdll: Fix its vs it's typos.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-08-01 20:57:23 -05:00
Frédéric Delanoy 07a87666a1 ntdll: Fix a typo in an comment.
Signed-off-by: Frédéric Delanoy <frederic.delanoy@gmail.com>
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-05-18 21:18:17 +09:00
Sebastian Lackner a919a02ac3 ntdll: Don't warn about unsupported environment version 3.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2016-03-31 15:57:32 +09:00
Sebastian Lackner 381c034be3 ntdll: Wait_thread_proc should not terminate on user APC.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2015-10-09 20:56:27 +09:00
Francois Gouget e0e2ee3487 ntdll: Add a trailing '\n' to a FIXME() trace. 2015-08-07 23:50:20 +09:00
Sebastian Lackner 5bd9d58016 ntdll: Mark newly spawned worker threads as busy. 2015-07-29 22:23:56 +02:00
Sebastian Lackner 9562e81810 ntdll: Reimplement RtlQueueWorkItem on top of new threadpool API. 2015-07-28 09:54:18 +02:00
Sebastian Lackner b687fee66f ntdll: Fix incorrect assignment in assert statement (Coverity). 2015-07-13 14:44:40 +09:00
Sebastian Lackner f65f645c3f ntdll: Add missing calls to RtlExitUserThread. 2015-07-08 16:02:24 +09:00
Sebastian Lackner 0021569778 ntdll: Try to merge threadpool wait queue buckets if possible.
When the number of elements per bucket is too small, then try to reduce
the number of threads by merging buckets. This is to ensure that the
number of running wait queue threads doesn't get too big.
2015-07-06 14:49:39 +09:00
Sebastian Lackner 185247576b ntdll: Implement TpSetWait and TpWaitForWait. 2015-07-06 14:49:39 +09:00
Sebastian Lackner f1be5dcac0 ntdll: Implement threadpool wait queues.
To implement waiting for an arbitrary number of handles, we group them
in buckets up to (MAXIMUM_WAIT_OBJECTS - 1) objects, and then assign a
dedicated wait queue thread. The last handle is used to notify about
changes.
2015-07-06 14:49:38 +09:00
Sebastian Lackner 4523a54c62 ntdll: Implement TpAllocWait and TpReleaseWait. 2015-07-06 14:34:20 +09:00
Sebastian Lackner cb2aae1af8 ntdll: Implement threadpool timer queues. 2015-07-03 13:06:41 +09:00
Sebastian Lackner bd7cb07358 ntdll: Implement TpAllocTimer and TpReleaseTimer. 2015-07-03 13:06:31 +09:00
Sebastian Lackner 775d3dcecb ntdll: Implement TpDisassociateCallback and add a separate group completion event. 2015-07-03 13:06:15 +09:00
Sebastian Lackner 8965511957 ntdll: Implement TpCallbackUnloadDllOnCompletion. 2015-07-02 14:54:13 +09:00
Sebastian Lackner 15110b1770 ntdll: Implement TpCallbackSetEventOnCompletion. 2015-07-02 14:54:04 +09:00
Sebastian Lackner eb39cb1323 ntdll: Implement TpCallbackReleaseSemaphoreOnCompletion. 2015-07-02 14:53:50 +09:00
Sebastian Lackner 02ee5bb52d ntdll: Implement TpCallbackReleaseMutexOnCompletion.
Various internal details about the order and error handling of completion
actions are documented in "Concurrent Programming on Windows" by Joe Duffy.
2015-07-02 14:53:41 +09:00
Sebastian Lackner a9dd37be68 ntdll: Implement TpCallbackLeaveCriticalSectionOnCompletion.
An instance can only have one completion of each type, trying to add a
second one leads to an exception on Windows.
2015-07-02 14:53:21 +09:00
Sebastian Lackner eb974bcd7a ntdll: Implement instance objects and the TpCallbackMayRunLong function.
The instance is marked as long-running even if TpCallbackMayRunLong fails,
a second call will lead to an exception on Windows.
2015-07-02 14:53:02 +09:00
Sebastian Lackner 8fc2430c2a ntdll: Implement threadpool RaceDll environment variable. 2015-07-02 14:52:44 +09:00
Sebastian Lackner fa114f122b ntdll: Add support for threadpool finalization callback. 2015-07-02 14:52:38 +09:00
Sebastian Lackner 1839ce8697 ntdll: Add support for threadpool group cancel callback. 2015-07-02 14:52:27 +09:00
Sebastian Lackner e4c38f6bad ntdll: Implement threadpool work item functions. 2015-07-01 19:18:15 +09:00
Sebastian Lackner 68d92bceed ntdll: Implement threadpool cleanup group functions. 2015-07-01 19:18:14 +09:00
Sebastian Lackner 7d9ec31e19 ntdll: Implement TpSetPoolMinThreads. 2015-07-01 19:18:14 +09:00
Sebastian Lackner d56984a03d ntdll: Implement TpSetPoolMaxThreads. 2015-07-01 19:18:13 +09:00
Sebastian Lackner db9fc9141e ntdll: Implement TpSimpleTryPost and basic threadpool infrastructure. 2015-07-01 19:18:13 +09:00
Sebastian Lackner 41b24f2168 ntdll: Move all structs and definitions to the beginning in threadpool.c. 2015-03-17 14:52:07 +09:00
Sebastian Lackner ae309c2d00 ntdll: Move static threadpool variables into a struct. 2015-03-10 15:33:20 +09:00
Nikolay Sivov 7b7d8374a4 ntdll: NtWaitForMultipleObjects()'s third arguments means 'wait_any', not 'wait_all'. 2014-09-01 13:03:07 +02:00
Sebastian Lackner 7ba4d119c1 ntdll: Use condition variable for RtlQueueWorkItem implementation. 2014-03-12 10:41:26 +01:00
Sebastian Lackner 9277fcfdb4 ntdll: Fix possible race-condition in iocp poller code. 2014-03-11 19:39:29 +01:00
Sebastian Lackner 23adc9aaed ntdll: Fix incorrect value passed to RtlDeleteTimerQueueEx. 2014-01-30 10:35:53 +01:00
Alexandre Julliard 2810c5647f ntdll: Add a magic number to validate timer queue pointers. 2013-08-20 20:13:58 +02:00
Jörg Höhle 2f0b93ca13 ntdll: Stabilize CreateTimerQueueTimer callbacks over time. 2013-02-19 19:50:54 +01:00
Jörg Höhle 4f6db78ca0 ntdll: Use the monotonic time counter also for timer queues. 2013-02-07 15:54:34 +01:00
Jörg Höhle 602807c2a5 ntdll: Do not execute callbacks past DeleteTimer(INVALID_HANDLE_VALUE). 2012-10-31 18:08:02 +01:00
Michael Stefaniuc abef6ab366 ntdll: Avoid TRUE:FALSE conditional expressions. 2012-08-14 11:58:40 +02:00