mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 15:29:26 +01:00
CA-379640: Do not reset remote consoles if they're still attempting connection to a VM
This prevents `AccessViolationException`s being called, as they're hit when two instances of `AxMSTSCLib.AxMsRdpClient9` call `Connect` on the same IP + Port combination, which results in the same memory being accessed in unmanaged code. Signed-off-by: Danilo Del Busso <danilo.delbusso@cloud.com>
This commit is contained in:
parent
9ea0a53447
commit
b8eb2b5549
@ -504,6 +504,9 @@ namespace XenAdmin.ConsoleView
|
||||
}
|
||||
}
|
||||
|
||||
private readonly object _rdpConnectionLock = new object();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates the actual VNC or RDP client control.
|
||||
/// </summary>
|
||||
@ -519,15 +522,27 @@ namespace XenAdmin.ConsoleView
|
||||
this.Controls.Clear();
|
||||
//console size with some offset to accomodate focus rectangle
|
||||
Size currentConsoleSize = new Size(this.Size.Width - CONSOLE_SIZE_OFFSET, this.Size.Height - CONSOLE_SIZE_OFFSET);
|
||||
|
||||
// Stop the old client.
|
||||
if (RemoteConsole != null)
|
||||
|
||||
lock (_rdpConnectionLock)
|
||||
{
|
||||
wasFocused = RemoteConsole.ConsoleControl != null && RemoteConsole.ConsoleControl.Focused;
|
||||
RemoteConsole.DisconnectAndDispose();
|
||||
RemoteConsole = null;
|
||||
this.vncPassword = null;
|
||||
// Stop the old client.
|
||||
if (RemoteConsole != null)
|
||||
{
|
||||
var preventResetConsole = false;
|
||||
wasFocused = RemoteConsole.ConsoleControl != null && RemoteConsole.ConsoleControl.Focused;
|
||||
if (RemoteConsole is RdpClient client && client.IsAttemptingConnection)
|
||||
{
|
||||
preventResetConsole = true;
|
||||
}
|
||||
if(!preventResetConsole)
|
||||
{
|
||||
RemoteConsole.DisconnectAndDispose();
|
||||
RemoteConsole = null;
|
||||
}
|
||||
this.vncPassword = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Reset
|
||||
haveTriedLoginWithoutPassword = false;
|
||||
|
Loading…
Reference in New Issue
Block a user