llvmpipe: Avoid deadlock when unloading opengl32.dll
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 7 Nov 2014 16:15:43 +0000 (16:15 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 7 Nov 2014 21:00:06 +0000 (21:00 +0000)
commit706ad3b649e6a75fdac9dc9acc3caa9e6067b853
tree3ba95737f1e3413ec6e24f2c7a595661d4a9cc68
parentedb7b1c56622bf4e68cd363c06b6443d07900b7a
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 <sroland@vmware.com>
Cc: 10.2 10.3 <mesa-stable@lists.freedesktop.org>
src/gallium/drivers/llvmpipe/lp_rast.c