Skip to content

Fix IPC socket deleted on multi-output setups - #2

Open
apostolosSotiropoulos wants to merge 1 commit into
AR-CADE:mainfrom
apostolosSotiropoulos:fix-serve-called-multiple-times
Open

apostolosSotiropoulos wants to merge 1 commit into
AR-CADE:mainfrom
apostolosSotiropoulos:fix-serve-called-multiple-times

Conversation

@apostolosSotiropoulos

Copy link
Copy Markdown

The i3-ipc plugin extends per_output_plugin_instance_t, so one instance is created per output. This caused two issues:

  1. serve() was called once per output, each call unlinking the previous socket file before creating a new one. With N outputs, the socket was created and deleted N times.

  2. When an output was disabled/removed, fini() triggered handle_display_destroy() which closed and unlinked the socket, even though other output instances still needed it.

Fix serve() to only initialize the socket once (guard on ipc_socket > 0), and simplify fini() to only unbind events without destroying the server. The server cleanup on actual shutdown is already handled by the wl_display_add_destroy_listener registered in serve().

The i3-ipc plugin extends per_output_plugin_instance_t, so one instance
is created per output. This caused two issues:

1. serve() was called once per output, each call unlinking the previous
   socket file before creating a new one. With N outputs, the socket
   was created and deleted N times.

2. When an output was disabled/removed, fini() triggered
   handle_display_destroy() which closed and unlinked the socket,
   even though other output instances still needed it.

Fix serve() to only initialize the socket once (guard on ipc_socket > 0),
and simplify fini() to only unbind events without destroying the server.
The server cleanup on actual shutdown is already handled by the
wl_display_add_destroy_listener registered in serve().
@AR-CADE

AR-CADE commented Feb 26, 2026

Copy link
Copy Markdown
Owner

I think you're right, this plugin shouldn't be instantiated "per output" because it can lead to unexpected behaviors, and what's more, it's useless in this case...

this plugin was initially a singleton plugin, so replacing "per_output_plugin_instance_t" with "plugin_interface_t" should do the trick.

My advice is to revert your changes and try to do only this:

-#include "wayfire/per-output-plugin.hpp"
+#include <wayfire/output-layout.hpp>
+#include <wayfire/plugin.hpp>


-class ipc_t : public wf::per_output_plugin_instance_t
+class ipc_t : public wf::plugin_interface_t


-DECLARE_WAYFIRE_PLUGIN(wf::per_output_plugin_t<ipc_t>);
+DECLARE_WAYFIRE_PLUGIN(ipc_t);

Let me know if it works for you, and if so, can you please modify your PR to only contains thoses changes,

thanks...

@AR-CADE AR-CADE added the question Further information is requested label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants