[RFC wayland 11/12] wayland-client: duplicate fd on connect

David Herrmann dh.herrmann at googlemail.com
Fri Oct 12 04:09:19 PDT 2012


On Thu, Oct 11, 2012 at 11:37 PM, David Herrmann
<dh.herrmann at googlemail.com> wrote:
> We need our own copy of the file-descriptor in each wl_display so we can
> close() it on error to wake up the main-thread.
>
> Signed-off-by: David Herrmann <dh.herrmann at googlemail.com>
> ---

Pekka and I discussed this on IRC and we came to the conclusion that
it is easier if we change semantics here. Calling
wl_display_connect_to_fd() should pass ownership of the FD to
wl_display. So if the user wants to keep the FD, they have to dup() it
before passing it to wl_display_connect_to_fd().

This would make the dup() call inside of wl_display unneeded and we
can simply always call close(). Furthermore, we couldn't think of any
reason why the user would want to keep an FD around, anyway. So if we
use wl_display_connect_to_fd() we would call close() on the FD
afterwards, because we don't need the copy.

If we pass FD ownership to wl_display, we can avoid all that without
making the API less powerful. If nobody objects, I will fix this in
the next revision.

Regards
David


More information about the wayland-devel mailing list