[release/5.0] Update IpcStreamFactory state machine to handle being started on a thread that ends #44267
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #43711 to release/5.0
/cc @josalem
Customer Impact
#39176
In custom hosting scenarios, the runtime can be started on a thread that ends before the application ends. In this case, all Overlapped IO on Windows that was started on that thread is cancelled. This scenario causes the state machine inside the Diagnostic Server that polls for connections to go into an unrecoverable error state. This will cause the Diagnostic Server to be unable to receive commands and for the polling thread to use ~12% CPU. (see #43711 for more details)
Testing
There is a repro available in #39176 and I have manually confirmed both the bad behavior and that this patch fixes the bad behavior.
Risk
This is a minimal risk patch. All the tests for expected behavior are passing and the specific case for bad behavior has been manually tested and shown to be fixed.
CC @tommcdon @noahfalk