-
Notifications
You must be signed in to change notification settings - Fork 77
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
Yamux implementation #281
Yamux implementation #281
Conversation
Fix FIN handling in yamux
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.
Some points to fix and some potential points to discuss:
- Track window per stream?
- How to handle sending when window size is 0?
9109252
to
dd78586
Compare
dd78586
to
bb29ac7
Compare
Thanks for the review @Nashatyrev ! I think that's all fixed now except the locking on empty window size. I'm open to suggestions for that. |
I could just put the pending writes in a queue I guess and process them on the window update thread.. |
That would solve the threading, but then it's not propagating back the back pressure up the stack. Any ideas? |
I'm not 100% sure how it is supposed to correctly handle backpressure in Netty. My understanding:
So what we most likely should do is to switch With respect to buffering I see the following possible options:
|
Forgive my netty ignorance, but how do we set isWritable? I can only see a method channel.fireChannelWritabilityChanged() In terms of DOS protection we should probably do the latter:
|
Good question... I don't know 😃 My intuition is that we may need to override the following methods in the
Or we need to check out what's going on with the That looks like a topic which needs a deep dive. Thus I would suggest to just skip So we should probably just support buffering with some configurable max size.
Agree 👍 |
There is one other thing I haven't implemented which is not in the spec, but is kind of a libp2p consensus - limiting unACKed streams to 256. But that can also be a future PR I think. |
@Nashatyrev Could you clarify the remaining buffering stuff you'd like done? |
I believe the option below should work pretty fine:
|
per connection max write buffer size limit.
I've had a go at that. Let me know what you think. |
…. Derive YamuxHandler from it
Did some old code refactoring here. Could you please have a look: Peergos#7 |
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.
Ok, let's give this PR a go, to not block further work.
Meanwhile I'm planning to add some more generic Mux tests and tests specific to Yamux
Relates to #27
@Nashatyrev That sounds great. Some bugs we've found in real world use have suggested some good tests:
|
@ianopolous I'm also not sure how |
My only guess is that it's used to communicate the type of error? To maybe not try reconnecting? |
Yeah, probably. That makes sense. Then I guess we should remove that line YamuxType.GO_AWAY -> onRemoteClose(msg.id) cause it has no sense since I think there should be some another handling mechanism if any other application needs to utilize that disconnect option. Yamux.goAway(errorCode: Int)
Yamux.getRemoteGoAwayCode(): Int |
Filed an issue #286 on this |
Part of #272
The spec is here https://github.com/hashicorp/yamux/blob/master/spec.md