From a5fa3999910d42031951838a4ef39bf92dbd3426 Mon Sep 17 00:00:00 2001 From: Lucas Pardue Date: Tue, 10 Sep 2024 10:26:38 +0100 Subject: [PATCH] h3: avoid unnecessary work on control streams Previously, quiche's poll() function would attempt to do work on control or QPACK streams, whether they were readable or not. Since we encourage apps to call poll() after each read loop, this could result in wasted work. With this change, we'll return early if the stream is not actually readable. --- quiche/src/h3/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quiche/src/h3/mod.rs b/quiche/src/h3/mod.rs index 7a44a5c9e0..3f3a211811 100644 --- a/quiche/src/h3/mod.rs +++ b/quiche/src/h3/mod.rs @@ -2130,6 +2130,10 @@ impl Connection { return Err(Error::ClosedCriticalStream); } + if !conn.stream_readable(stream_id) { + return Err(Error::Done); + } + match self.process_readable_stream(conn, stream_id, true) { Ok(ev) => return Ok(ev),