gnome-remote-desktop/SOURCES/0001-session-vnc-Don-t-requeue-close-session-idle.patch
2021-10-08 11:27:39 +00:00

85 lines
2.6 KiB
Diff

From add0ea34fd1d6835c99aebeb4e56b805b38e53ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Mon, 1 Oct 2018 18:02:39 +0200
Subject: [PATCH 1/2] session/vnc: Don't requeue close session idle
If being closed due to a PipeWire error, RFB will still process state
and invoke callbacks when cleaning up the RFB screen, meaning we'd
requeue the close session idle handler. Avoid this by avoiding
requeueing if there is already one queued, and don't mark is as unqueued
until after actually stopping the session.
---
src/grd-session-vnc.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/grd-session-vnc.c b/src/grd-session-vnc.c
index ce4dd29..3c98eeb 100644
--- a/src/grd-session-vnc.c
+++ b/src/grd-session-vnc.c
@@ -165,6 +165,16 @@ grd_session_vnc_draw_buffer (GrdSessionVnc *session_vnc,
rfbProcessEvents (session_vnc->rfb_screen, 0);
}
+static void
+maybe_queue_close_session_idle (GrdSessionVnc *session_vnc)
+{
+ if (session_vnc->close_session_idle_id)
+ return;
+
+ session_vnc->close_session_idle_id =
+ g_idle_add (close_session_idle, session_vnc);
+}
+
static void
handle_client_gone (rfbClientPtr rfb_client)
{
@@ -172,8 +182,7 @@ handle_client_gone (rfbClientPtr rfb_client)
g_debug ("VNC client gone");
- session_vnc->close_session_idle_id =
- g_idle_add (close_session_idle, session_vnc);
+ maybe_queue_close_session_idle (session_vnc);
}
static void
@@ -670,12 +679,6 @@ grd_session_vnc_stop (GrdSession *session)
g_debug ("Stopping VNC session");
- if (session_vnc->close_session_idle_id)
- {
- g_source_remove (session_vnc->close_session_idle_id);
- session_vnc->close_session_idle_id = 0;
- }
-
g_clear_object (&session_vnc->pipewire_stream);
grd_session_vnc_detach_source (session_vnc);
@@ -683,6 +686,12 @@ grd_session_vnc_stop (GrdSession *session)
g_clear_object (&session_vnc->connection);
g_clear_pointer (&session_vnc->rfb_screen->frameBuffer, g_free);
g_clear_pointer (&session_vnc->rfb_screen, (GDestroyNotify) rfbScreenCleanup);
+
+ if (session_vnc->close_session_idle_id)
+ {
+ g_source_remove (session_vnc->close_session_idle_id);
+ session_vnc->close_session_idle_id = 0;
+ }
}
static gboolean
@@ -703,8 +712,7 @@ on_pipwire_stream_closed (GrdVncPipeWireStream *stream,
{
g_warning ("PipeWire stream closed, closing client");
- session_vnc->close_session_idle_id =
- g_idle_add (close_session_idle, session_vnc);
+ maybe_queue_close_session_idle (session_vnc);
}
static void
--
2.17.1