[mutter] display: Make sure ping serials are never reused



commit 9b58033375212878730e1ffebd6f22bba89be41b
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Sat Dec 7 15:24:31 2019 +0100

    display: Make sure ping serials are never reused
    
    Using a timestamp twice in a row (e.g. when activating two windows in
    response to the same event or due to other bugs) will break the window
    detection and show a close dialog on the wrong window. This is a grave
    error that should never happen, so check every timestamp before sending
    the ping for uniqueness and if the timestamp was already used and its
    ping is still pending, log a warning message and don't send the ping.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/891

 src/core/display.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/core/display.c b/src/core/display.c
index 889bdb542..eb0377ad3 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -2063,6 +2063,7 @@ void
 meta_display_ping_window (MetaWindow *window,
                           guint32     serial)
 {
+  GSList *l;
   MetaDisplay *display = window->display;
   MetaPingData *ping_data;
 
@@ -2076,6 +2077,19 @@ meta_display_ping_window (MetaWindow *window,
   if (!meta_window_can_ping (window))
     return;
 
+  for (l = display->pending_pings; l; l = l->next)
+    {
+      MetaPingData *ping_data = l->data;
+
+      if (serial == ping_data->serial)
+        {
+          meta_warning ("Ping serial %u was reused for window %s, "
+                        "previous use was for window %s.\n",
+                        serial, window->desc, ping_data->window->desc);
+          return;
+        }
+    }
+
   ping_data = g_new (MetaPingData, 1);
   ping_data->window = window;
   ping_data->serial = serial;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]