Skip to content

Commit

Permalink
Prevent busy loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Apr 5, 2024
1 parent c2b0721 commit 5d314b6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions neqo-http3/src/send_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ impl SendMessage {
fn get_stream_info(&self) -> Http3StreamInfo {
Http3StreamInfo::new(self.stream_id(), Http3StreamType::Http)
}

fn stream_avail_send_space(&self, conn: &Connection) -> Res<usize> {
conn.stream_avail_send_space(self.stream_id())
.map_err(|e| Error::map_stream_send_errors(&e.into()))
}
}

impl Stream for SendMessage {
Expand All @@ -174,9 +179,7 @@ impl SendStream for SendMessage {
if self.stream.has_buffered_data() {
return Ok(0);
}
let available = conn
.stream_avail_send_space(self.stream_id())
.map_err(|e| Error::map_stream_send_errors(&e.into()))?;
let available = self.stream_avail_send_space(conn)?;
if available <= 2 {
return Ok(0);
}
Expand Down Expand Up @@ -253,7 +256,8 @@ impl SendStream for SendMessage {
Error::HttpInternal(6),
)?;
qtrace!([self], "done sending request");
} else {
} else if self.stream_avail_send_space(conn)? > 2 {
// TODO: Deduplicate and document 2
// DataWritable is just a signal for an application to try to write more data,
// if writing fails it is fine. Therefore we do not need to properly check
// whether more credits are available on the transport layer.
Expand Down

0 comments on commit 5d314b6

Please sign in to comment.