-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix two stream close issues (b/73167987, b/73382103). #810
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same problem we keep having: we can't notify our delegate in an inconsistent state. We shouldn't interleave mutating actions and notifcations. Therefore
[self notifyStreamInterruptedWIthError:error]
must be the last action we take here.We've actually have observed that callback filter is ineffective. There's a race condition it doesn't handle, which is why #790 was required.
The whole thing needs to be redesigned, but in the meantime I think we should clear the delegate, but just above the notification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, wow. Thanks for flagging this. I didn't know there was history here. I assume the problem is that the callbackFilter is applied /before/ the messages are dispatched to our queue and so even though we suppress callbacks in this code there could still be callbacks already waiting on our queue.
I don't think setting delegate to nil above notifyStreamInterruptedWithError helps any, since in the case I'm fixing the delegate is getting immediately re-assigned to a non-nil value (by notifyStreamInterruptedWithError). So those pending callbacks would just be delivered to the new delegate, which is exactly what we want to prevent with the callbackFilter. :-/
I think the fix is probably to make callbackFilter do the dispatch onto the dispatch queue in addition to doing the filtering so it can actually do its job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the other options would be to remove the dispatch in
writeValue:
(there's a "TODO(mcg): remove the double-dispatch once GRPCCall at head is released.")... If you think we can actually do that, that would also be sufficient to fix the race condition if I'm understanding it correctly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I had to implement it convince myself it would work, so it to you in a PR.
notifyStreamInterruptedWithError:
because the delegate must be non-nil for that to even do anything useful. The two interesting implementations nil it out for themselves anyway, though they are careful to do so before the invocation, which is correct.FSTCallbackFilter
so perhaps new further action is required.