Ensure that forked process do not see invalid blocking operations. #13343
+65
−13
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.
When forking a child process, while simultaneously there is a thread which is blocking on an IO operation, if that IO instance is closed in the child process, it will try and interrupt the blocking operation which no longer exists (in the child process).
For a little bit of background: when forking, all native threads except for the one doing the fork operation go away. That means stack allocated data structures on those threads become invalid, e.g.
struct rb_io_blocking_operation
. We track the fork generation to know whether the entries in the blocking_operations list are valid or not, and if the fork generation mismatches, we clear the list. This is the same technique used byQueue
.