-
Notifications
You must be signed in to change notification settings - Fork 190
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
inbound stream deduplication #396
Conversation
other, dup := p.inboundStreams[peer] | ||
if dup { | ||
log.Debugf("duplicate inbound stream from %s; resetting other stream", peer) | ||
other.Reset() |
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.
Does the muxer guarantee that an outstanding read from this stream will error out immediately as soon as we reset it? Can't remember.
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 don't really know, but it shouldn't matter much. As long as it happens promptly enough we should be fine.
comm.go
Outdated
p.inboundStreamsMx.Lock() | ||
if p.inboundStreams[peer] == s { | ||
delete(p.inboundStreams, peer) | ||
} | ||
p.inboundStreamsMx.Unlock() |
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.
Probably should put this in a defer
, so that it's also run on other return paths.
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.
Well, there are no other relevant return code paths. The only other return is in the context cancellation case, where we don't care because we are shutting down.
Having said that, it is probably cleaner to do it in a defer so why not.
This adds deduplication for inbound pubsub streams so that we always have only a single inbound stream from a peer; last one wins.