Commit f065e7be authored by Jonas Ådahl's avatar Jonas Ådahl

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.
parent ddaaa064
......@@ -163,6 +163,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)
{
......@@ -170,8 +180,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
......@@ -602,12 +611,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);
......@@ -615,6 +618,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, 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
......@@ -635,8 +644,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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment