Fix for SSH remoting when SSH client abruptly terminates (#4123)
* Fix for SSH remoting when SSH client abruptly terminates * Put error message in localizable string resource * Renamed error string per code review request * Removed extra error==null check
This commit is contained in:
parent
a8e3d8968f
commit
a2922d6ac4
|
@ -1511,8 +1511,10 @@ namespace System.Management.Automation.Remoting.Client
|
|||
while (true)
|
||||
{
|
||||
string error = ReadError(reader);
|
||||
if (string.IsNullOrEmpty(error))
|
||||
|
||||
if (error.Length == 0)
|
||||
{
|
||||
// Ignore
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1524,6 +1526,10 @@ namespace System.Management.Automation.Remoting.Client
|
|||
HandleSSHError(psrte);
|
||||
}
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Normal reader thread end.
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string errorMsg = (e.Message != null) ? e.Message : string.Empty;
|
||||
|
@ -1548,7 +1554,13 @@ namespace System.Management.Automation.Remoting.Client
|
|||
// Blocking read from StdError stream
|
||||
string error = reader.ReadLine();
|
||||
|
||||
if (string.IsNullOrEmpty(error) ||
|
||||
if (error == null)
|
||||
{
|
||||
// Stream is closed unexpectedly.
|
||||
throw new PSInvalidOperationException(RemotingErrorIdStrings.SSHAbruptlyTerminated);
|
||||
}
|
||||
|
||||
if ((error.Length == 0) ||
|
||||
error.IndexOf("WARNING:", StringComparison.OrdinalIgnoreCase) > -1)
|
||||
{
|
||||
// Handle as interactive warning message
|
||||
|
|
|
@ -1636,4 +1636,7 @@ All WinRM sessions connected to Windows PowerShell session configurations, such
|
|||
<data name="InvalidRoleCapabilityFileExtension" xml:space="preserve">
|
||||
<value>The provided role capability file {0} does not have the required .psrc extension.</value>
|
||||
</data>
|
||||
<data name="SSHAbruptlyTerminated" >
|
||||
<value>The SSH transport process has abruptly terminated causing this remote session to break.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
Loading…
Reference in a new issue