Fix race condition in grpc_tsi_alts_shutdown#14296
Merged
jiangtaoli2016 merged 1 commit intogrpc:masterfrom Feb 7, 2018
Merged
Fix race condition in grpc_tsi_alts_shutdown#14296jiangtaoli2016 merged 1 commit intogrpc:masterfrom
jiangtaoli2016 merged 1 commit intogrpc:masterfrom
Conversation
|
|
|
There was a problem hiding this comment.
why not use the following to avoid goto.
if (g_alts_resource.cq != nullptr) {
...
}
|
jiangtaoli2016
approved these changes
Feb 2, 2018
jiangtaoli2016
left a comment
There was a problem hiding this comment.
LGTM. Could you squash the commits?
|
cbc96fb to
f65b6a1
Compare
|
f65b6a1 to
d173770
Compare
|
|
|
|
|
1 similar comment
|
|
|
|
d173770 to
6d55db0
Compare
|
|
|
Contributor
Author
|
It seems the errors are not related to this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
In the original implementation, cq is destroyed before being drained which resulted in a race condition between TSI and main threads. That is, it was possible for the main thread to invoke grpc_completion_queue_destroy() on cq while the TSI thread is still actively using it. The correct implementation is cq should be drained before grpc_completion_queue_destroy() gets invoked. We need to call grpc_completion_queue_shutdown(), wait for TSI thread to finish working on it, then signal the main thread to continue with the destroy.