From d2c98bcee9c25bacd8353becbd4bc381038cc4b3 Mon Sep 17 00:00:00 2001 From: cedrozor Date: Tue, 19 Nov 2019 16:28:19 +0100 Subject: [PATCH] fixed an issue on session sharing, was in read-only mode instead of granted control (thanks medfki) improved cleanup of guest(s) on session disconnect --- CHANGELOG | 2 +- Myrtille.Web/Default.aspx.cs | 4 +++ .../src/Clients/RemoteSessionProcessClient.cs | 33 +++++++++++++++++++ Myrtille.Web/src/RemoteSessionManager.cs | 5 +++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 48bdd4a..c679f80 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -2019-11-09 Version 2.7.0 (stable) +2019-11-19 Version 2.7.0 (stable) * HOTFIX * fixed a critical issue with FreeRDP (exit code 131085) when using an RD license server configured in "per device" mode, past the 120 days of the RDS grace period updated readme and documentation about the RDS role the browser "heartbeat" (used to detect if the browser window/tab was closed) is now on a different timer than the periodical fullscreen update (config.js; default 10 secs) diff --git a/Myrtille.Web/Default.aspx.cs b/Myrtille.Web/Default.aspx.cs index eab90a3..665bd08 100644 --- a/Myrtille.Web/Default.aspx.cs +++ b/Myrtille.Web/Default.aspx.cs @@ -243,6 +243,10 @@ protected void Page_Load( // cleanup Session.Remove(HttpSessionStateVariables.RemoteSession.ToString()); + if (Session[HttpSessionStateVariables.GuestInfo.ToString()] != null) + { + Session.Remove(HttpSessionStateVariables.GuestInfo.ToString()); + } RemoteSession = null; } } diff --git a/Myrtille.Web/src/Clients/RemoteSessionProcessClient.cs b/Myrtille.Web/src/Clients/RemoteSessionProcessClient.cs index c4b1df4..5c78403 100644 --- a/Myrtille.Web/src/Clients/RemoteSessionProcessClient.cs +++ b/Myrtille.Web/src/Clients/RemoteSessionProcessClient.cs @@ -228,6 +228,39 @@ public void ProcessExited(int exitCode) remoteSessions.Remove(_remoteSessionManager.RemoteSession.Id); } + // retrieve the remote session guest(s) + var guests = new List(); + var sharedSessions = (IDictionary)_application[HttpApplicationStateVariables.SharedRemoteSessions.ToString()]; + foreach (var sharingInfo in sharedSessions.Values) + { + if (sharingInfo.RemoteSession.Id.Equals(_remoteSessionManager.RemoteSession.Id)) + { + guests.Add(sharingInfo); + } + } + + // remove them + foreach (var guest in guests) + { + if (guest.GuestInfo.Active && guest.HttpSession != null) + { + if (guest.HttpSession[HttpSessionStateVariables.RemoteSession.ToString()] != null) + { + guest.HttpSession.Remove(HttpSessionStateVariables.RemoteSession.ToString()); + } + + if (guest.HttpSession[HttpSessionStateVariables.GuestInfo.ToString()] != null) + { + guest.HttpSession.Remove(HttpSessionStateVariables.GuestInfo.ToString()); + } + + if (guest.RemoteSession.ActiveGuests > 0) + { + guest.RemoteSession.ActiveGuests--; + } + } + sharedSessions.Remove(guest.GuestInfo.Id); + } // recycle the application pool when there is no active remote session bool idleAppPoolRecycling; diff --git a/Myrtille.Web/src/RemoteSessionManager.cs b/Myrtille.Web/src/RemoteSessionManager.cs index 2f6a66f..553dbbb 100644 --- a/Myrtille.Web/src/RemoteSessionManager.cs +++ b/Myrtille.Web/src/RemoteSessionManager.cs @@ -544,6 +544,11 @@ public void ProcessInputs(HttpSessionState session, string data) { lock (_guestsIdleTimeoutLock) { + if (!_guestsIdleTimeout.ContainsKey(session.SessionID)) + { + _guestsIdleTimeout.Add(session.SessionID, new CancellationTokenSource()); + } + var guestIdleTimeout = _guestsIdleTimeout[session.SessionID]; if (guestIdleTimeout != null) {