-
Notifications
You must be signed in to change notification settings - Fork 8.1k
[Regression] Fix for error on Enter-PSSession exit #4693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1403,6 +1403,7 @@ internal sealed class SSHClientSessionTransportManager : OutOfProcessClientSessi | |
| private StreamWriter _stdInWriter; | ||
| private StreamReader _stdOutReader; | ||
| private StreamReader _stdErrReader; | ||
| private bool _connectionEstablished; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this have an explicit initialization to false?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need as CLR guarantees all type fields are initialized to zero.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be an explicit initialization to false?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need as CLR guarantees all type fields are initialized to zero. |
||
| private const string _threadName = "SSHTransport Reader Thread"; | ||
|
|
||
| #endregion | ||
|
|
@@ -1464,7 +1465,12 @@ internal override void CreateAsync() | |
| internal override void CloseAsync() | ||
| { | ||
| base.CloseAsync(); | ||
| CloseConnection(); | ||
|
|
||
| if (!_connectionEstablished) | ||
| { | ||
| // If the connection is not yet estalished then clean up any existing connection state. | ||
| CloseConnection(); | ||
| } | ||
| } | ||
|
|
||
| #endregion | ||
|
|
@@ -1641,6 +1647,9 @@ private void ProcessReaderThread(object state) | |
| } | ||
| else | ||
| { | ||
| // The first received PSRP message from the server indicates that the connection is established and that PSRP is running. | ||
| if (!_connectionEstablished) { _connectionEstablished = true; } | ||
|
|
||
| // Normal output data. | ||
| HandleOutputDataReceived(data); | ||
| } | ||
|
|
@@ -2410,3 +2419,4 @@ internal override void Close(Exception reasonForClose) | |
| #endregion | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this an order of operations issue? It seems like the flag should be set before the call to Open().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the ShouldCloseOnPop property? No. A runspace pop cannot occur before this method completes.