-
Notifications
You must be signed in to change notification settings - Fork 161
Buffer inner h2 streams #1580
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
Merged
istio-testing
merged 4 commits into
istio:master
from
Stevenjin8:steven/buffer-inner-h2-streams
Jul 7, 2025
Merged
Buffer inner h2 streams #1580
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -594,9 +594,10 @@ mod test { | |
| } | ||
|
|
||
| /// This is really a test for TokioH2Stream, but its nicer here because we have access to | ||
| /// streams | ||
| /// streams. | ||
| /// Most important, we make sure there are no panics. | ||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
| async fn small_reads() { | ||
| async fn read_buffering() { | ||
| let (mut pool, srv) = setup_test(3).await; | ||
|
|
||
| let key = key(&srv, 2); | ||
|
|
@@ -612,13 +613,28 @@ mod test { | |
| let c = pool.send_request_pooled(&key.clone(), req()).await.unwrap(); | ||
| let mut c = TokioH2Stream::new(c); | ||
| c.write_all(b"abcde").await.unwrap(); | ||
| let mut b = [0u8; 0]; | ||
| // Crucially, this should error rather than panic. | ||
| if let Err(e) = c.read(&mut b).await { | ||
| assert_eq!(e.kind(), io::ErrorKind::Other); | ||
| } else { | ||
| panic!("Should have errored"); | ||
| } | ||
| let mut b = [0u8; 100]; | ||
| // Properly buffer reads and don't error | ||
|
Member
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.
|
||
| assert_eq!(c.read(&mut b).await.unwrap(), 8); | ||
| assert_eq!(&b[..8], b"poolsrv\n"); // this is added by itself | ||
| assert_eq!(c.read(&mut b[..1]).await.unwrap(), 1); | ||
| assert_eq!(&b[..1], b"a"); | ||
| assert_eq!(c.read(&mut b[..1]).await.unwrap(), 1); | ||
| assert_eq!(&b[..1], b"b"); | ||
| assert_eq!(c.read(&mut b[..1]).await.unwrap(), 1); | ||
| assert_eq!(&b[..1], b"c"); | ||
| assert_eq!(c.read(&mut b).await.unwrap(), 2); // there are only two bytes left | ||
| assert_eq!(&b[..2], b"de"); | ||
|
|
||
| // Once we drop the pool, we should still retained the buffered data, | ||
| // but then we should error. | ||
| c.write_all(b"abcde").await.unwrap(); | ||
| assert_eq!(c.read(&mut b[..3]).await.unwrap(), 3); | ||
| assert_eq!(&b[..3], b"abc"); | ||
| drop(pool); | ||
| assert_eq!(c.read(&mut b[..2]).await.unwrap(), 2); | ||
| assert_eq!(&b[..2], b"de"); | ||
| assert!(c.read(&mut b).await.is_err()); | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
|
|
||
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.
I think this can be simplified (but give equivilent) like so:
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.
Mostly agree. What's the point of
let this = &mut self;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 not needed and was just copy and pasted from others and not cleaned up. Its common to need to do things like that for projections