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.
It turns out that Cronet transport never used the stream refcount object (passed in by
init_stream
). When a call is unref'ed, the stream may be destroyed before the corresponding Cronet stream is done with callbacks, thus introducing crash.This PR refs the refcount object when a stream is initiated at Cronet transport layer. Unref happens when Cronet issues a finishing callback (either on_succeeded, on_failed, or on_canceled). This guarantees that even the call is unref'ed, the stream context is still valid when the finishing callback happens
The second commit polishes the exec_ctx usage in Cronet transport. In particular, when Cronet issues a callback, the execution context is created immediately. The context is flushed when the callback returns. This is the recommended way of using exec_ctx. It also guarantees that there is no recursive exec_ctx init/flush in a single callback's call stack.