-
Notifications
You must be signed in to change notification settings - Fork 38
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
changed Limiter.requests to AtomicLong #214
changed Limiter.requests to AtomicLong #214
Conversation
Hey, @yuriykulikov thanks for report and PR! So looks like the right fix for making rsocket-kotlin compatible with protocol and other implementations would be:
Will you do this, or I can create PR with proposed changes? |
Hello @olme04, This sounds reasonable and was also my first thought. However, I was confused after digging into https://rsocket.io/about/protocol/#flow-control which states: In the end, both approaches effectively achieve the same.
I will be glad to implement the changes as you have suggested. Let me summarize how I have understand how the Limiter should work:
|
@yuriykulikov yes, it should work like this. |
This avoids Int overflow when client is misbehaving and is sending multiple RequestN frames with n=Int.MAX_VALUE This closes rsocket#213
8e8d79b
to
b5b37c6
Compare
Hey @yuriykulikov, thx for implementing it! TL;DR: the problem is, that Int.MAX_VALUE overall is reasonable request, which doesn't mean, that request is unbounded. |
Hey @olme04, I will adjust my implementation to remove the magic meaning of Int.MAX value. Protection against overflow is still relevant even if the U flag is implemented. |
Related to rsocket#213
} | ||
|
||
@Test | ||
fun testStreamRequestNUnbounded() = test { |
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 test fails, could you check?
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 didn't run all tests before pushing 🤦. I will push the change as a third commit, but I assume all three will be squashed. Or should I squash myself?
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.
just do third commit
they will be squashed on merge
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.
Pushed the commit :)
Overall LGTM, but please check test |
@yuriykulikov thx for the contribution! All tests passed! |
Glad I could contribute 😊 |
This avoids Int overflow when client is misbehaving and is sending multiple RequestN frames with n=Int.MAX_VALUE
Motivation:
This closes #213
Modifications:
Changed AtomicInt to AtomicLong. Overflow is still possible after that, however it will require the client sending a RequestN frame 2147483647 times. Not sure if the request value can become negative under other circumstances. If not, unsigned long can be used instead or the value can be asserted to be positive.
Result:
Server won't hang after receiving RequestN frames anymore.