diff options
author | Emil Velikov <[email protected]> | 2018-08-29 18:13:14 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2018-10-03 13:38:05 +0100 |
commit | 6ccc435e7ad92bb0ba77d3fdb48c7127ba71239e (patch) | |
tree | 6ca059b425d4b452bcfe76a634d4d852bed0f6d8 /src/gallium/auxiliary/vl | |
parent | 7b8d1b313cd01bb916898d8bb92a566534e37677 (diff) |
pipe-loader: move dup(fd) within pipe_loader_drm_probe_fd
Currently pipe_loader_drm_probe_fd takes ownership of the fd given.
To match that, pipe_loader_release closes it.
Yet we have many instances which do not want the change of ownership,
and thus duplicate the fd before passing it to the pipe-loader.
Move the dup() within pipe-loader, explicitly document that and document
all the cases through the codebase.
A trivial git grep -2 pipe_loader_release makes things as obvious as it
gets ;-)
Cc: Leo Liu <[email protected]>
Cc: Thomas Hellstrom <[email protected]>
Cc: Axel Davy <[email protected]>
Cc: Patrick Rudolph <[email protected]>
Signed-off-by: Emil Velikov <[email protected]>
Reviewed-by: Thomas Hellstrom <[email protected]>
Reviewed-by: Axel Davy <[email protected]> (for nine)
Diffstat (limited to 'src/gallium/auxiliary/vl')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_winsys_dri.c | 11 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_winsys_drm.c | 10 |
2 files changed, 7 insertions, 14 deletions
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c index cb779010a9c..137885d9475 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c @@ -29,7 +29,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <fcntl.h> #include <X11/Xlib-xcb.h> #include <X11/extensions/dri2tokens.h> @@ -471,6 +470,8 @@ vl_dri2_screen_create(Display *display, int screen) vl_compositor_reset_dirty_area(&scrn->dirty_areas[0]); vl_compositor_reset_dirty_area(&scrn->dirty_areas[1]); + /* The pipe loader duplicates the fd */ + close(fd); free(authenticate); free(connect); free(dri2_query); @@ -479,15 +480,12 @@ vl_dri2_screen_create(Display *display, int screen) return &scrn->base; release_pipe: - if (scrn->base.dev) { + if (scrn->base.dev) pipe_loader_release(&scrn->base.dev, 1); - fd = -1; - } free_authenticate: free(authenticate); close_fd: - if (fd != -1) - close(fd); + close(fd); free_connect: free(connect); free_query: @@ -515,5 +513,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen) vl_dri2_destroy_drawable(scrn); scrn->base.pscreen->destroy(scrn->base.pscreen); pipe_loader_release(&scrn->base.dev, 1); + /* There is no user provided fd */ FREE(scrn); } diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c index df8809c501c..94eb6d74ee7 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_drm.c +++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c @@ -26,7 +26,6 @@ **************************************************************************/ #include <assert.h> -#include <fcntl.h> #include "pipe/p_screen.h" #include "pipe-loader/pipe_loader.h" @@ -48,10 +47,7 @@ vl_drm_screen_create(int fd) if (!vscreen) return NULL; - if (fd < 0 || (new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) < 0) - goto free_screen; - - if (pipe_loader_drm_probe_fd(&vscreen->dev, new_fd)) + if (pipe_loader_drm_probe_fd(&vscreen->dev, fd)) vscreen->pscreen = pipe_loader_create_screen(vscreen->dev); if (!vscreen->pscreen) @@ -68,10 +64,7 @@ vl_drm_screen_create(int fd) release_pipe: if (vscreen->dev) pipe_loader_release(&vscreen->dev, 1); - else - close(new_fd); -free_screen: FREE(vscreen); return NULL; } @@ -83,5 +76,6 @@ vl_drm_screen_destroy(struct vl_screen *vscreen) vscreen->pscreen->destroy(vscreen->pscreen); pipe_loader_release(&vscreen->dev, 1); + /* CHECK: The VAAPI loader/user preserves ownership of the original fd */ FREE(vscreen); } |