[Mesa-dev] [PATCH 07/13] squash! egl: add EGL_ANDROID_native_fence_sync

Chad Versace chad.versace at intel.com
Sat Jul 9 00:00:57 UTC 2016


Close the sync fd *after* the sync's refcount drops to 0.
---
 src/egl/drivers/dri2/egl_dri2.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index a9d351e..c7b81ce 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2407,8 +2407,17 @@ dri2_egl_unref_sync(struct dri2_egl_display *dri2_dpy,
                     struct dri2_egl_sync *dri2_sync)
 {
    if (p_atomic_dec_zero(&dri2_sync->refcount)) {
-      if (dri2_sync->base.Type == EGL_SYNC_REUSABLE_KHR)
+      switch (dri2_sync->base.Type) {
+      case EGL_SYNC_REUSABLE_KHR:
          cnd_destroy(&dri2_sync->cond);
+         break;
+      case EGL_SYNC_NATIVE_FENCE_ANDROID:
+         if (dri2_sync->base.SyncFd != EGL_NO_NATIVE_FENCE_FD_ANDROID)
+            close(dri2_sync->base.SyncFd);
+         break;
+      default:
+         break;
+      }
 
       if (dri2_sync->fence)
          dri2_dpy->fence->destroy_fence(dri2_dpy->dri_screen, dri2_sync->fence);
@@ -2544,9 +2553,6 @@ dri2_destroy_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync)
       }
    }
 
-   if (sync->SyncFd != EGL_NO_NATIVE_FENCE_FD_ANDROID)
-      close(sync->SyncFd);
-
    dri2_egl_unref_sync(dri2_dpy, dri2_sync);
 
    return ret;
-- 
2.9.0.rc2



More information about the mesa-dev mailing list