-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
ignore received frames on a stream locally reset #174
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8f74cd4
ignore received frames on a stream locally reset
seanmonstar 4d2a5e9
change from using an extra ordermap to having a pending_reset Queue
seanmonstar 066a3a1
add reset stream config to Server builder
seanmonstar 27ae627
remove unrelated server reset test
seanmonstar a2582f1
add comment about checking stream.is_pending_reset
seanmonstar d1d6db0
automatically release connection capacity for ignored frames
seanmonstar 921cd81
add comment about release connection capacity for ignored frame
seanmonstar fa695a0
add comment for why expired check is outside poll2 loop
seanmonstar e9226ab
undo removal of deny warnings lint
seanmonstar 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,12 @@ pub(super) struct Counts { | |
|
||
/// Current number of locally initiated streams | ||
num_recv_streams: usize, | ||
|
||
/// Maximum number of pending locally reset streams | ||
max_reset_streams: usize, | ||
|
||
/// Current number of pending locally reset streams | ||
num_reset_streams: usize, | ||
} | ||
|
||
impl Counts { | ||
|
@@ -30,6 +36,8 @@ impl Counts { | |
num_send_streams: 0, | ||
max_recv_streams: config.remote_max_initiated.unwrap_or(usize::MAX), | ||
num_recv_streams: 0, | ||
max_reset_streams: config.local_reset_max, | ||
num_reset_streams: 0, | ||
} | ||
} | ||
|
||
|
@@ -72,6 +80,22 @@ impl Counts { | |
self.num_send_streams += 1; | ||
} | ||
|
||
/// Returns true if the number of pending reset streams can be incremented. | ||
pub fn can_inc_num_reset_streams(&self) -> bool { | ||
self.max_reset_streams > self.num_reset_streams | ||
} | ||
|
||
/// Increments the number of pending reset streams. | ||
/// | ||
/// # Panics | ||
/// | ||
/// Panics on failure as this should have been validated before hand. | ||
pub fn inc_num_reset_streams(&mut self) { | ||
assert!(self.can_inc_num_reset_streams()); | ||
|
||
self.num_reset_streams += 1; | ||
} | ||
|
||
pub fn apply_remote_settings(&mut self, settings: &frame::Settings) { | ||
if let Some(val) = settings.max_concurrent_streams() { | ||
self.max_send_streams = val as usize; | ||
|
@@ -87,19 +111,26 @@ impl Counts { | |
F: FnOnce(&mut Self, &mut store::Ptr) -> U, | ||
{ | ||
let is_counted = stream.is_counted(); | ||
let is_pending_reset = stream.is_pending_reset_expiration(); | ||
|
||
// Run the action | ||
let ret = f(self, &mut stream); | ||
|
||
self.transition_after(stream, is_counted); | ||
self.transition_after(stream, is_counted, is_pending_reset); | ||
|
||
ret | ||
} | ||
|
||
// TODO: move this to macro? | ||
pub fn transition_after(&mut self, mut stream: store::Ptr, is_counted: bool) { | ||
pub fn transition_after(&mut self, mut stream: store::Ptr, is_counted: bool, is_reset_counted: bool) { | ||
if stream.is_closed() { | ||
stream.unlink(); | ||
if !stream.is_pending_reset_expiration() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that I'm following this logic (and that it is correct), but it would be super helpful to add a comment describing how |
||
stream.unlink(); | ||
|
||
if is_reset_counted { | ||
self.dec_num_reset_streams(); | ||
} | ||
} | ||
|
||
if is_counted { | ||
// Decrement the number of active streams. | ||
|
@@ -115,9 +146,16 @@ impl Counts { | |
|
||
fn dec_num_streams(&mut self, id: StreamId) { | ||
if self.peer.is_local_init(id) { | ||
assert!(self.num_send_streams > 0); | ||
self.num_send_streams -= 1; | ||
} else { | ||
assert!(self.num_recv_streams > 0); | ||
self.num_recv_streams -= 1; | ||
} | ||
} | ||
|
||
fn dec_num_reset_streams(&mut self) { | ||
assert!(self.num_reset_streams > 0); | ||
self.num_reset_streams -= 1; | ||
} | ||
} |
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
Oops, something went wrong.
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.
Can this stay enabled? I assume this line was accidentally committed.