Fix crash when releasing dispatch sources in GSMultiHandle #37
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.
The logic here comes from readdle/swift-corelibs-foundation@819eab9#diff-ab36fc9e1b50ee4f5efa7d24cb3f806160e52c31f97724605527faab21a52bbbR465
More details: swiftlang/swift-corelibs-foundation#4791 (comment)
We use a separate queue for read/write sources which allows us to cancel & release them synchronously
This fixes the first problem mentioned but note that
Is still an issue. There's a fix for that available that avoids using dispatch altogether and implements a different Sources event emitter for Windows specifically, but in practice I haven't seen this be an issue and the code is complicated. We are also bandaging over by commenting out the assertion in libDispatch
FYI the 'real' fix is in 0c1a3e8
The followup cleanup commit is just to simplify setting up and tearing down the socket sources since tracing through the original code was unnecessarily complicated