libgl-gdi: Avoid hangs on DLL_PROCESS_DETACH.
authorRob Schneider <Swizzle@t-online.de>
Tue, 15 Jan 2013 19:49:12 +0000 (11:49 -0800)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 15 Jan 2013 22:16:09 +0000 (14:16 -0800)
At process exit DLL_PROCESS_DETACH is signaled to DllMain(), where then
a final cleanup is triggered.  In stw_cleanup() code is triggered that
tries to communicate a shutdown to the spawned threads -- however at
that time those threads have already been terminated by the OS and so
the process hangs.

v2: skip stw_cleanup_thread() too

Signed-off-by: José Fonseca <jfonseca@vmware.com>
src/gallium/targets/libgl-gdi/libgl_gdi.c

index 112904ab5fe88e6a690e31564808d34d9d9216dd..3f7dc00b0801c4b8453807beeb9065827175c6fd 100644 (file)
@@ -159,8 +159,10 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
       break;
 
    case DLL_PROCESS_DETACH:
-      stw_cleanup_thread();
-      stw_cleanup();
+      if (lpReserved == NULL) {
+         stw_cleanup_thread();
+         stw_cleanup();
+      }
       break;
    }
    return TRUE;