Fix a big source of races in CHTTP2 code #20139
Merged
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.
Replace direct closure callback calls with GRPC_CLOSURE_SCHED.
This was probably causing a huge lot of bugs in our codebase.
Since the closures can be those from combiners, we were running closures outside of combiners by running the callback function directly. This would cause all sorts of races in the chttp2 code.
Closure callback functions do not consume a ref to the error that is passed in. The error is instead consumed by the scheduler. By directly calling the callback function, we would also be leaking errors.
Fixes #19901, #18885, #18944.
Potentially also fixes #18942, #18941, #18884