[Mesa-dev] [RFC 06/12] squash! egl: add EGL_ANDROID_native_fence_sync

Chad Versace chadversary at chromium.org
Mon Oct 10 17:43:53 UTC 2016


From: Chad Versace <chad.versace at intel.com>

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 0c15c85..70ee270 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2503,8 +2503,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);
@@ -2638,9 +2647,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.10.0



More information about the mesa-dev mailing list