[Mesa-dev] [PATCH] Don't manually close fds for queryImage. drm uses CLOEXEC

Daniel Stone daniel at fooishbar.org
Thu Apr 14 15:12:01 UTC 2016


Hi,

On 14 April 2016 at 13:19, Chokshi, Mitul <mitul.chokshi at intel.com> wrote:
> If create_wl_buffer() closes the file descriptor returned by
> dri2_dpy->image->queryImage then OS hands out the same file
> descriptor number to other process which then experiences error
> when fd is closed due to CLOEXEC.

I don't really understand the intent of this change.

The __DRI_IMAGE_ATTRIB_FD query creates a new file descriptor for the
DRIImage, which is then passed to wl_drm_create_prime_buffer.
wl_drm_create_prime_buffer internally, as part of the Wayland client
library wrapper, duplicates the fd for its own internal use and passes
it to the compositor.

After this point, there is no reason to keep the fd around. If the fd
is not closed, it will be leaked, and the buffer can never be freed as
the reference count will never be zero, thanks to the leaked fd.

None of this has anything to do with CLOEXEC.

What is the exact problem you see, and how do you reproduce it?

Cheers,
Daniel


More information about the mesa-dev mailing list