darwin: Eliminate a possible race condition while destroying a surface
authorJeremy Huddleston <jeremyhu@apple.com>
Sat, 28 Apr 2012 01:36:33 +0000 (18:36 -0700)
committerJeremy Huddleston <jeremyhu@apple.com>
Thu, 17 May 2012 01:58:30 +0000 (18:58 -0700)
Introduced by: c60ffd2840036af1ea6f2b6c6e1e9014bb8e2c34
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
src/glx/apple/apple_glx_surface.c

index d42fa3b326915aacbc34685fa7569cac250107e9..915520286b07b0167ed11d82901affd61b5b9393 100644 (file)
@@ -207,9 +207,6 @@ apple_glx_surface_destroy(unsigned int uid)
       d->types.surface.pending_destroy = true;
       d->release(d);
 
-      /* apple_glx_drawable_find_by_uid returns a locked drawable */
-      d->unlock(d);
-
       /* 
        * We release 2 references to the surface.  One was acquired by
        * the find, and the other was leftover from a context, or 
@@ -220,6 +217,9 @@ apple_glx_surface_destroy(unsigned int uid)
        * to actually destroy it when the pending_destroy is processed
        * by a glViewport callback (see apple_glx_context_update()).
        */
-      d->destroy(d);
+      if (!d->destroy(d)) {
+          /* apple_glx_drawable_find_by_uid returns a locked drawable */
+          d->unlock(d);
+      }
    }
 }