From 15b8692dcf5bc32ccc35008ef78cef2cf63d4223 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Tue, 30 Apr 2019 06:23:44 -0700 Subject: [PATCH] Fix spurious ZeroRttRejected on outgoing 0.5-RTT streams --- quinn-proto/src/lib.rs | 6 ++++-- quinn/src/connection.rs | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/quinn-proto/src/lib.rs b/quinn-proto/src/lib.rs index 19ca29335..e200eaf3e 100644 --- a/quinn-proto/src/lib.rs +++ b/quinn-proto/src/lib.rs @@ -89,12 +89,14 @@ pub enum Side { impl Side { #[inline] - fn is_client(self) -> bool { + /// Shorthand for `self == Side::Client` + pub fn is_client(self) -> bool { self == Side::Client } #[inline] - fn is_server(self) -> bool { + /// Shorthand for `self == Side::Server` + pub fn is_server(self) -> bool { self == Side::Server } } diff --git a/quinn/src/connection.rs b/quinn/src/connection.rs index dc084ec25..6767d38a2 100644 --- a/quinn/src/connection.rs +++ b/quinn/src/connection.rs @@ -171,7 +171,10 @@ impl Connection { { let mut conn = self.0.lock().unwrap(); if let Some(x) = conn.inner.open(Directionality::Uni) { - let _ = send.send(Ok((x, conn.inner.is_handshaking()))); + let _ = send.send(Ok(( + x, + conn.inner.side().is_client() && conn.inner.is_handshaking(), + ))); } else { conn.uni_opening.push_back(send); // We don't notify the driver here because there's no way to ask the peer for more @@ -194,7 +197,10 @@ impl Connection { { let mut conn = self.0.lock().unwrap(); if let Some(x) = conn.inner.open(Directionality::Bi) { - let _ = send.send(Ok((x, conn.inner.is_handshaking()))); + let _ = send.send(Ok(( + x, + conn.inner.side().is_client() && conn.inner.is_handshaking(), + ))); } else { conn.bi_opening.push_back(send); // We don't notify the driver here because there's no way to ask the peer for more