Skip to content

libweston: Introduce safer emission of wayland signals

Alexandros Frantzis requested to merge afrantzis/weston:weston-signal into main

Wayland signals (wl_signal) do not reliably handle changes to the notification list during signal emission. Such scenarios occasionally come up (e.g., #415 (closed)) and can be difficult to investigate and debug.

The first commit in the MR introduces the weston_signal_emit_mutable() function (copied from wlr_signal_emit_safe from wlroots) which can be used in place of wl_signal_emit() and which safely implements the following behavior regarding notification list changes:

  1. Listeners deleted during a signal emission and which have not already been notified at the time of deletion are not notified by that emission.

  2. New listeners added during emission are ignored by that emission.

  3. Listeners which are deleted and then readded during emission are ignored by that emission.

  4. Repurposing a listener during a signal emission without an explicit removal and re-addition is not supported.

The second commit in this MR changes the wl_surface::destroy_signal to use weston_signal_emit_safe, both as an example of using weston_signal, and as a fix for #415 (closed).

If we agree on migrating to weston_signal_emit_safe() I will update the whole codebase accordingly.

Edited by Marius Vlad

Merge request reports

Loading