Remove deadlock in #1247

#1247 was caused by a loop of the putty control calling the tab dispose and back again. Created a flag to indicate the ConnectionTab that the closing process was called by the protocol and not the user.
This commit is contained in:
Camilo Alvarez
2019-02-07 17:39:40 -05:00
parent 54bb9a8f5a
commit b0bf31b29c
3 changed files with 28 additions and 21 deletions

View File

@@ -236,11 +236,8 @@ namespace mRemoteNG.Connection.Protocol
try
{
Console.WriteLine(@"Skipping Dispose for now!");
PuttyProcess.Close();
// TODO: Figure out why this hangs...
//PuttyProcess.Dispose();
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strPuttyDisposeFailed + Environment.NewLine + @"SKIPPING DISPOSE - CAUSES HANG IN THIS BUILD!!!", true);
PuttyProcess.Close();
PuttyProcess.Dispose();
}
catch (Exception ex)
{

View File

@@ -13,11 +13,18 @@ namespace mRemoteNG.UI.Tabs
{
public partial class ConnectionTab : DockContent
{
/// <summary>
///Silent close ignores the popup asking for confirmation
/// </summary>
public bool silentClose { get; set; }
/// <summary>
/// Protocol close ignores the interface controller cleanup and the user confirmation dialog
/// </summary>
public bool protocolClose { get; set; }
public ConnectionTab()
{
InitializeComponent();
InitializeComponent();
GotFocus += ConnectionTab_GotFocus;
}
@@ -28,34 +35,37 @@ namespace mRemoteNG.UI.Tabs
protected override void OnFormClosing(FormClosingEventArgs e)
{
if(!silentClose)
if(!protocolClose)
{
if (Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.All)
if (!silentClose)
{
var result = CTaskDialog.MessageBox(this, GeneralAppInfo.ProductName, string.Format(Language.strConfirmCloseConnectionPanelMainInstruction, TabText), "", "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.YesNo, ESysIcons.Question, ESysIcons.Question);
if (CTaskDialog.VerificationChecked)
if (Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.All)
{
Settings.Default.ConfirmCloseConnection--;
}
if (result == DialogResult.No)
{
e.Cancel = true;
var result = CTaskDialog.MessageBox(this, GeneralAppInfo.ProductName, string.Format(Language.strConfirmCloseConnectionPanelMainInstruction, TabText), "", "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.YesNo, ESysIcons.Question, ESysIcons.Question);
if (CTaskDialog.VerificationChecked)
{
Settings.Default.ConfirmCloseConnection--;
}
if (result == DialogResult.No)
{
e.Cancel = true;
}
else
{
((InterfaceControl)Tag)?.Protocol.Close();
}
}
else
{
// close without the confirmation prompt...
((InterfaceControl)Tag)?.Protocol.Close();
}
}
else
{
// close without the confirmation prompt...
((InterfaceControl)Tag)?.Protocol.Close();
}
}
else
{
((InterfaceControl)Tag)?.Protocol.Close();
}
base.OnFormClosing(e);
}

View File

@@ -741,7 +741,7 @@ namespace mRemoteNG.UI.Window
var protocolBase = sender as ProtocolBase;
if (!(protocolBase?.InterfaceControl.Parent is ConnectionTab tabPage)) return;
if (tabPage.Disposing) return;
tabPage.silentClose = true;
tabPage.protocolClose = true;
Invoke(new Action(() => tabPage.Close()));
}