Mesa (master): wgl: Do not reach out and destroy contexts on cleanup.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Fri Feb 12 11:40:24 UTC 2010


Module: Mesa
Branch: master
Commit: e475ae920a4f6026b78b0bbe80c83cf4060f610e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e475ae920a4f6026b78b0bbe80c83cf4060f610e

Author: José Fonseca <jfonseca at vmware.com>
Date:   Fri Feb 12 11:00:22 2010 +0000

wgl: Do not reach out and destroy contexts on cleanup.

Simply skip cleanup when contexts are still active.

This addresses two issues:

- in some situations the ICD DLL may be unloaded before the DLL that is
  using GL contexts is, so we may receive GL calls after stw_cleanup.

- when aborting (exception, or control-c) the contexts may have been left
  in an inconsistent state and attempting to destroy can cause
  unpredictable results.

---

 src/gallium/state_trackers/wgl/stw_device.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c
index 7785aba..ce6fe5f 100644
--- a/src/gallium/state_trackers/wgl/stw_device.c
+++ b/src/gallium/state_trackers/wgl/stw_device.c
@@ -152,24 +152,26 @@ stw_cleanup_thread(void)
 void
 stw_cleanup(void)
 {
-   unsigned i;
+   DHGLRC dhglrc;
 
    debug_printf("%s\n", __FUNCTION__);
 
    if (!stw_dev)
       return;
    
+   /*
+    * Abort cleanup if there are still active contexts. In some situations
+    * this DLL may be unloaded before the DLL that is using GL contexts is.
+    */
    pipe_mutex_lock( stw_dev->ctx_mutex );
-   {
-      /* Ensure all contexts are destroyed */
-      i = handle_table_get_first_handle(stw_dev->ctx_table);
-      while (i) {
-         DrvDeleteContext(i);
-         i = handle_table_get_next_handle(stw_dev->ctx_table, i);
-      }
-      handle_table_destroy(stw_dev->ctx_table);
-   }
+   dhglrc = handle_table_get_first_handle(stw_dev->ctx_table);
    pipe_mutex_unlock( stw_dev->ctx_mutex );
+   if (dhglrc) {
+      debug_printf("%s: contexts still active -- cleanup aborted\n", __FUNCTION__);
+      return;
+   }
+
+   handle_table_destroy(stw_dev->ctx_table);
 
    stw_framebuffer_cleanup();
    




More information about the mesa-commit mailing list