diff options
author | Michel Dänzer <mdaenzer@redhat.com> | 2024-10-03 12:33:56 +0200 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-10-22 16:26:09 +0000 |
commit | 91b5a003a5f48df2920e628c1f0a0bd02f476280 (patch) | |
tree | a5544ae67780d021b2b28d5194ac982cf157e4db | |
parent | b306df5a6060beea82b5157c3603593527b220b0 (diff) |
xwayland/glamor/gbm: Don't close fence_fd after xwl_glamor_wait_fence
eglCreateSyncKHR takes ownership of the file descriptor. Noticed by
inspection.
While we're at it, move the fence_fd declaration to the scope where
it's used.
Last but not least, close the fd in xwl_glamor_wait_fence when bailing
before calling eglCreateSyncKHR, and document that it takes ownership.
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1712>
-rw-r--r-- | hw/xwayland/xwayland-glamor-gbm.c | 7 | ||||
-rw-r--r-- | hw/xwayland/xwayland-glamor.c | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index 92241bd1e..45f18a47c 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -1516,16 +1516,15 @@ xwl_glamor_gbm_wait_syncpts(PixmapPtr pixmap) #ifdef DRI3 struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen); struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap); - int fence_fd; if (!xwl_screen->glamor || !xwl_pixmap) return; if (xwl_pixmap->syncobj) { - fence_fd = xwl_pixmap->syncobj->export_fence(xwl_pixmap->syncobj, - xwl_pixmap->timeline_point); + int fence_fd = xwl_pixmap->syncobj->export_fence(xwl_pixmap->syncobj, + xwl_pixmap->timeline_point); + xwl_glamor_wait_fence(xwl_screen, fence_fd); - close(fence_fd); } #endif /* DRI3 */ } diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c index c3aa483ff..6618a0a34 100644 --- a/hw/xwayland/xwayland-glamor.c +++ b/hw/xwayland/xwayland-glamor.c @@ -198,14 +198,17 @@ xwl_glamor_get_fence(struct xwl_screen *xwl_screen) return fence_fd; } +/* Takes ownership of fence_fd, specifically eglCreateSyncKHR does */ void xwl_glamor_wait_fence(struct xwl_screen *xwl_screen, int fence_fd) { EGLint attribs[3]; EGLSyncKHR sync; - if (!xwl_screen->glamor) + if (!xwl_screen->glamor) { + close(fence_fd); return; + } xwl_glamor_egl_make_current(xwl_screen); |