[gnome-remote-desktop] session-rdp: Stop leaking session sources when session creation fails
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] session-rdp: Stop leaking session sources when session creation fails
- Date: Tue, 5 Jul 2022 07:35:40 +0000 (UTC)
commit a18756ed59af5705139439b0be4ce7b0de7df79e
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Sat Jul 2 05:40:01 2022 +0200
session-rdp: Stop leaking session sources when session creation fails
Currently, the monitor layout update source is leaked, when the session
creation fails.
This GSource, however, must be destroyed, when the session is stopped
and not later.
To handle both the success and fail case, add a helper method, where
the existing session sources are cleared, when the session stops or
when it is disposed.
src/grd-session-rdp.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/src/grd-session-rdp.c b/src/grd-session-rdp.c
index 97572255..18c069ab 100644
--- a/src/grd-session-rdp.c
+++ b/src/grd-session-rdp.c
@@ -2180,6 +2180,21 @@ grd_session_rdp_new (GrdRdpServer *rdp_server,
return g_steal_pointer (&session_rdp);
}
+static void
+clear_session_sources (GrdSessionRdp *session_rdp)
+{
+ if (session_rdp->update_monitor_layout_source)
+ {
+ g_source_destroy (session_rdp->update_monitor_layout_source);
+ g_clear_pointer (&session_rdp->update_monitor_layout_source, g_source_unref);
+ }
+ if (session_rdp->pending_encode_source)
+ {
+ g_source_destroy (session_rdp->pending_encode_source);
+ g_clear_pointer (&session_rdp->pending_encode_source, g_source_unref);
+ }
+}
+
static gboolean
clear_pointer_bitmap (gpointer key,
gpointer value,
@@ -2239,12 +2254,7 @@ grd_session_rdp_stop (GrdSession *session)
g_clear_object (&rdp_peer_context->graphics_pipeline);
g_clear_pointer (&session_rdp->socket_thread, g_thread_join);
-
- if (session_rdp->update_monitor_layout_source)
- {
- g_source_destroy (session_rdp->update_monitor_layout_source);
- g_clear_pointer (&session_rdp->update_monitor_layout_source, g_source_unref);
- }
+ clear_session_sources (session_rdp);
peer->Close (peer);
g_clear_object (&session_rdp->connection);
@@ -2417,11 +2427,7 @@ grd_session_rdp_dispose (GObject *object)
{
GrdSessionRdp *session_rdp = GRD_SESSION_RDP (object);
- if (session_rdp->pending_encode_source)
- {
- g_source_destroy (session_rdp->pending_encode_source);
- g_clear_pointer (&session_rdp->pending_encode_source, g_source_unref);
- }
+ clear_session_sources (session_rdp);
g_assert (!session_rdp->graphics_thread);
g_clear_pointer (&session_rdp->graphics_context, g_main_context_unref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]