From 5d314b6061ca3a056a6428373d369f0f98727f64 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Fri, 5 Apr 2024 16:15:52 +0200 Subject: [PATCH] Prevent busy loop --- neqo-http3/src/send_message.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/neqo-http3/src/send_message.rs b/neqo-http3/src/send_message.rs index 15965c44f6..6fd721a185 100644 --- a/neqo-http3/src/send_message.rs +++ b/neqo-http3/src/send_message.rs @@ -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 { + conn.stream_avail_send_space(self.stream_id()) + .map_err(|e| Error::map_stream_send_errors(&e.into())) + } } impl Stream for SendMessage { @@ -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); } @@ -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.