-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
netty: Add option to limit RST_STREAM rate #10675
Conversation
The behavior purposefully mirrors that of Netty's AbstractHttp2ConnectionHandlerBuilder.decoderEnforceMaxRstFramesPerWindow(). That API is not available to our code as we extend the Http2ConnectionHandler, but we want our API to be able to delegate to Netty's in the future if that ever becomes possible.
if (maxRstCount > 0) { | ||
long now = System.nanoTime(); | ||
if (now - lastRstNanoTime > maxRstPeriodNanos) { | ||
lastRstNanoTime = now; | ||
rstCount = 1; | ||
} else { | ||
rstCount++; | ||
if (rstCount > maxRstCount) { | ||
throw Http2Exception.connectionError(Http2Error.ENHANCE_YOUR_CALM, "too_many_rststreams"); | ||
} | ||
} | ||
} |
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.
Extract this logic to a method? Would keep this method more concise and a well named new method would also communicate what this logic is for. Or a comment, as an alternative.
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.
"Enforce maxRstCount" as a comment seems a bit repetitive. And the description of how this should work is in the public documentation. Do you have an idea for something in particular that is helpful to communicate?
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 I was just looking for something to indicate this block of code IS the maxRstCount enforcement. But I don't feel strongly about it.
The behavior purposefully mirrors that of Netty's
AbstractHttp2ConnectionHandlerBuilder.decoderEnforceMaxRstFramesPerWindow(). That API is not available to our code as we extend the Http2ConnectionHandler, but we want our API to be able to delegate to Netty's in the future if that ever becomes possible.
CC @temawi