diff options
author | José Fonseca <[email protected]> | 2014-11-07 16:15:43 +0000 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2014-11-16 20:56:16 +0000 |
commit | f285c7eaafcb01545591c24c3f5c8adacbbfbdf7 (patch) | |
tree | 04f6b16598773af154b9b587a48a8e999b6773a9 | |
parent | 9cc26056ee13f25c5785fef81b31487f1429baa4 (diff) |
llvmpipe: Avoid deadlock when unloading opengl32.dll
On Windows, DllMain calls and thread creation/destruction are
serialized, so when llvmpipe is destroyed from DllMain waiting for the
rasterizer threads to finish will deadlock.
So, instead of waiting for rasterizer threads to have finished, simply wait for the
rasterizer threads to notify they are just about to finish.
Verified with this very simple program:
#include <windows.h>
int main() {
HMODULE hModule = LoadLibraryA("opengl32.dll");
FreeLibrary(hModule);
}
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=76252
Reviewed-by: Roland Scheidegger <[email protected]>
Cc: 10.2 10.3 <[email protected]>
(cherry picked from commit 706ad3b649e6a75fdac9dc9acc3caa9e6067b853)
Squashed together with:
llvmpipe: Call pipe_thread_wait() on Linux.
To address http://lists.freedesktop.org/archives/mesa-dev/2014-November/070569.html
In short, revert 706ad3b649e6a75fdac9dc9acc3caa9e6067b853 for non-Windows
OSes.
(cherry picked from commit d5b1731178378b3d828c74368f6bfe85edc10618)
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index a3420a21fbf..e168766e348 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -800,6 +800,10 @@ static PIPE_THREAD_ROUTINE( thread_function, init_data ) pipe_semaphore_signal(&task->work_done); } +#ifdef _WIN32 + pipe_semaphore_signal(&task->work_done); +#endif + return 0; } @@ -885,9 +889,15 @@ void lp_rast_destroy( struct lp_rasterizer *rast ) pipe_semaphore_signal(&rast->tasks[i].work_ready); } - /* Wait for threads to terminate before cleaning up per-thread data */ + /* Wait for threads to terminate before cleaning up per-thread data. + * We don't actually call pipe_thread_wait to avoid dead lock on Windows + * per https://bugs.freedesktop.org/show_bug.cgi?id=76252 */ for (i = 0; i < rast->num_threads; i++) { +#ifdef _WIN32 + pipe_semaphore_wait(&rast->tasks[i].work_done); +#else pipe_thread_wait(rast->threads[i]); +#endif } /* Clean up per-thread data */ |