Skip to content
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

feat: Use std::io::BufWriter with a 64KB buffer for dumping data #1752

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions neqo-bin/src/bin/client/http3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
collections::{HashMap, VecDeque},
fmt::Display,
fs::File,
io::Write,
io::{BufWriter, Write},
net::SocketAddr,
path::PathBuf,
rc::Rc,
Expand Down Expand Up @@ -255,8 +255,9 @@
match handler_type {
Self::Download => {
let out_file = get_output_file(url, &args.output_dir, all_paths);
let buf_writer = out_file.map(|file| BufWriter::with_capacity(64 * 1024, file));

Check warning on line 258 in neqo-bin/src/bin/client/http3.rs

View check run for this annotation

Codecov / codecov/patch

neqo-bin/src/bin/client/http3.rs#L258

Added line #L258 was not covered by tests
client.stream_close_send(client_stream_id).unwrap();
Box::new(DownloadStreamHandler { out_file })
Box::new(DownloadStreamHandler { buf_writer })

Check warning on line 260 in neqo-bin/src/bin/client/http3.rs

View check run for this annotation

Codecov / codecov/patch

neqo-bin/src/bin/client/http3.rs#L260

Added line #L260 was not covered by tests
}
Self::Upload => Box::new(UploadStreamHandler {
data: vec![42; args.upload_size],
Expand All @@ -269,12 +270,12 @@
}

struct DownloadStreamHandler {
out_file: Option<File>,
buf_writer: Option<BufWriter<File>>,
}

impl StreamHandler for DownloadStreamHandler {
fn process_header_ready(&mut self, stream_id: StreamId, fin: bool, headers: Vec<Header>) {
if self.out_file.is_none() {
if self.buf_writer.is_none() {

Check warning on line 278 in neqo-bin/src/bin/client/http3.rs

View check run for this annotation

Codecov / codecov/patch

neqo-bin/src/bin/client/http3.rs#L278

Added line #L278 was not covered by tests
println!("READ HEADERS[{stream_id}]: fin={fin} {headers:?}");
}
}
Expand All @@ -287,9 +288,9 @@
sz: usize,
output_read_data: bool,
) -> Res<bool> {
if let Some(out_file) = &mut self.out_file {
if let Some(buf_writer) = &mut self.buf_writer {

Check warning on line 291 in neqo-bin/src/bin/client/http3.rs

View check run for this annotation

Codecov / codecov/patch

neqo-bin/src/bin/client/http3.rs#L291

Added line #L291 was not covered by tests
if sz > 0 {
out_file.write_all(&data[..sz])?;
buf_writer.write_all(&data[..sz])?;

Check warning on line 293 in neqo-bin/src/bin/client/http3.rs

View check run for this annotation

Codecov / codecov/patch

neqo-bin/src/bin/client/http3.rs#L293

Added line #L293 was not covered by tests
}
return Ok(true);
} else if !output_read_data {
Expand All @@ -300,7 +301,7 @@
println!("READ[{}]: 0x{}", stream_id, hex(&data));
}

if fin && self.out_file.is_none() {
if fin && self.buf_writer.is_none() {

Check warning on line 304 in neqo-bin/src/bin/client/http3.rs

View check run for this annotation

Codecov / codecov/patch

neqo-bin/src/bin/client/http3.rs#L304

Added line #L304 was not covered by tests
println!("<FIN[{stream_id}]>");
}

Expand Down