Skip to content

platform-wl: Reuse wl_display between being checked and being used - #781

Merged
aperezdc merged 1 commit into
masterfrom
pgriffis/wayland-socket-closed
Apr 29, 2026
Merged

aperezdc merged 1 commit into
masterfrom
pgriffis/wayland-socket-closed

Conversation

@TingPing

Copy link
Copy Markdown
Member

In normal cases this shouldn't meaningfully change behavior.

However if WAYLAND_SOCKET is set to an fd then wl_display_disconnect() closes that fd leaving it in a state where it cannot be reused.

In normal cases this shouldn't meaningfully change behavior.

However if WAYLAND_SOCKET is set to an fd then wl_display_disconnect()
closes that fd leaving it in a state where it cannot be reused.

Fixes #728

@aperezdc aperezdc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even when I have a small doubt (see comment), this solves the actual issue of not being able to open the connection to the Wayland compositor when WAYLAND_SOCKET is defined in the environment, so I think we should merge it.

If we find later on that we do not want to keep the wl_display alive we make a patch later for that.

g_debug("Initializing Wayland...");

CogWlDisplay *display = cog_wl_display_create(NULL, error);
CogWlDisplay *display = cog_wl_display_create(g_steal_pointer(&checked_wl_display), error);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could do this only if WAYLAND_SOCKET was set? Or as an alternative, if the environment variable is set, we can dup() the file descriptor and open the duplicate for the check.

Either way, the idea is to avoid keeping a connected wl_display in case Cog ends up picking a different plugin in the end. But also I am not sure if it's worth the effort 🤔

@TingPing TingPing Apr 29, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried dup but it didn't work. It’s left in a bad state if it’s reused anyway.

Originally i also limited it to when that's set but AFAICT if the plugin is ever checked for support and returns TRUE it's always used, so there is no risk of it left open.

@aperezdc

Copy link
Copy Markdown
Member

The ARM cross-compilation is broken (#787) so let's merge this anyway.

@aperezdc
aperezdc merged commit b321571 into master Apr 29, 2026
3 of 5 checks passed
@aperezdc
aperezdc deleted the pgriffis/wayland-socket-closed branch April 29, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants