summaryrefslogtreecommitdiffstats
path: root/third_party/rust/neqo-http3/src/buffered_send_stream.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/neqo-http3/src/buffered_send_stream.rs
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/neqo-http3/src/buffered_send_stream.rs')
-rw-r--r--third_party/rust/neqo-http3/src/buffered_send_stream.rs51
1 files changed, 28 insertions, 23 deletions
diff --git a/third_party/rust/neqo-http3/src/buffered_send_stream.rs b/third_party/rust/neqo-http3/src/buffered_send_stream.rs
index 4f6761fa80..60da0512b5 100644
--- a/third_party/rust/neqo-http3/src/buffered_send_stream.rs
+++ b/third_party/rust/neqo-http3/src/buffered_send_stream.rs
@@ -7,7 +7,7 @@
use neqo_common::qtrace;
use neqo_transport::{Connection, StreamId};
-use crate::Res;
+use crate::{qlog, Res};
#[derive(Debug, PartialEq, Eq)]
pub enum BufferedStream {
@@ -38,7 +38,7 @@ impl BufferedStream {
/// # Panics
///
- /// If the `BufferedStream` is initialized more than one it will panic.
+ /// If the `BufferedStream` is initialized more than once, it will panic.
pub fn init(&mut self, stream_id: StreamId) {
debug_assert!(&Self::Uninitialized == self);
*self = Self::Initialized {
@@ -63,19 +63,23 @@ impl BufferedStream {
/// Returns `neqo_transport` errors.
pub fn send_buffer(&mut self, conn: &mut Connection) -> Res<usize> {
let label = ::neqo_common::log_subject!(::log::Level::Debug, self);
- let mut sent = 0;
- if let Self::Initialized { stream_id, buf } = self {
- if !buf.is_empty() {
- qtrace!([label], "sending data.");
- sent = conn.stream_send(*stream_id, &buf[..])?;
- if sent == buf.len() {
- buf.clear();
- } else {
- let b = buf.split_off(sent);
- *buf = b;
- }
- }
+ let Self::Initialized { stream_id, buf } = self else {
+ return Ok(0);
+ };
+ if buf.is_empty() {
+ return Ok(0);
+ }
+ qtrace!([label], "sending data.");
+ let sent = conn.stream_send(*stream_id, &buf[..])?;
+ if sent == 0 {
+ return Ok(0);
+ } else if sent == buf.len() {
+ buf.clear();
+ } else {
+ let b = buf.split_off(sent);
+ *buf = b;
}
+ qlog::h3_data_moved_down(conn.qlog_mut(), *stream_id, sent);
Ok(sent)
}
@@ -85,16 +89,17 @@ impl BufferedStream {
pub fn send_atomic(&mut self, conn: &mut Connection, to_send: &[u8]) -> Res<bool> {
// First try to send anything that is in the buffer.
self.send_buffer(conn)?;
- if let Self::Initialized { stream_id, buf } = self {
- if buf.is_empty() {
- let res = conn.stream_send_atomic(*stream_id, to_send)?;
- Ok(res)
- } else {
- Ok(false)
- }
- } else {
- Ok(false)
+ let Self::Initialized { stream_id, buf } = self else {
+ return Ok(false);
+ };
+ if !buf.is_empty() {
+ return Ok(false);
+ }
+ let res = conn.stream_send_atomic(*stream_id, to_send)?;
+ if res {
+ qlog::h3_data_moved_down(conn.qlog_mut(), *stream_id, to_send.len());
}
+ Ok(res)
}
#[must_use]