diff options
author | Keyu Tao <me@taoky.moe> | 2023-02-15 03:04:54 +0800 |
---|---|---|
committer | Keyu Tao <me@taoky.moe> | 2023-02-15 18:56:07 +0800 |
commit | 45375561bccd0a47ec94ed814d7805c840079f0e (patch) | |
tree | 17d41830fcc9c7eea86ea121e353701f2990bcad | |
parent | 9181dd153caff6e3ebfb70419444e0430cfb74fa (diff) | |
download | gnome-desktop-45375561bccd0a47ec94ed814d7805c840079f0e.tar.gz |
Fix idle monitor watch leak
When an idle monitor watch is added and then removed by application,
it is possible that watch->dead is marked when on_watch_added()
is running. However, in this condition libgnome-desktop does not
actually remove this watch in upstream (meta). This idle monitor
watch leak may affect the performance of mutter when it has been
running for a few days.
-rw-r--r-- | libgnome-desktop/gnome-idle-monitor.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libgnome-desktop/gnome-idle-monitor.c b/libgnome-desktop/gnome-idle-monitor.c index 677ddf5c..1cbad8e1 100644 --- a/libgnome-desktop/gnome-idle-monitor.c +++ b/libgnome-desktop/gnome-idle-monitor.c @@ -375,6 +375,7 @@ on_watch_added (GObject *object, GnomeIdleMonitor *monitor; GError *error; GVariant *res; + guint upstream_id; error = NULL; res = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), result, &error); @@ -391,15 +392,22 @@ on_watch_added (GObject *object, return; } + g_variant_get (res, "(u)", &upstream_id); + g_variant_unref (res); + if (watch->dead) { + if (upstream_id) { + meta_dbus_idle_monitor_call_remove_watch (watch->monitor->priv->proxy, + upstream_id, + NULL, NULL, NULL); + } idle_monitor_watch_unref (watch); return; } monitor = watch->monitor; - g_variant_get (res, "(u)", &watch->upstream_id); - g_variant_unref (res); + watch->upstream_id = upstream_id; g_hash_table_insert (monitor->priv->watches_by_upstream_id, GINT_TO_POINTER (watch->upstream_id), watch); idle_monitor_watch_unref (watch); |