diff --git a/quinn-h3/src/connection.rs b/quinn-h3/src/connection.rs index 496081934..5468a16d5 100644 --- a/quinn-h3/src/connection.rs +++ b/quinn-h3/src/connection.rs @@ -75,9 +75,9 @@ impl ConnectionRef { recv_decoder: None, blocked_streams: BTreeMap::new(), send_unis: [ - SendUni::new(StreamType::CONTROL, quic.clone()), - SendUni::new(StreamType::ENCODER, quic.clone()), - SendUni::new(StreamType::DECODER, quic), + SendUni::new(StreamType::CONTROL, quic.open_uni()), + SendUni::new(StreamType::ENCODER, quic.open_uni()), + SendUni::new(StreamType::DECODER, quic.open_uni()), ], })), }) diff --git a/quinn-h3/src/streams.rs b/quinn-h3/src/streams.rs index 6c8b870f8..6dd3bf7e2 100644 --- a/quinn-h3/src/streams.rs +++ b/quinn-h3/src/streams.rs @@ -94,17 +94,16 @@ pub struct SendUni { } impl SendUni { - pub(super) fn new(ty: StreamType, quic: quinn::Connection) -> Self { + pub(super) fn new(ty: StreamType, open_uni: quinn::OpenUni) -> Self { Self { ty, - state: SendUniState::New(quic), + state: SendUniState::Opening(open_uni), data: VecDeque::with_capacity(2), } } } enum SendUniState { - New(quinn::Connection), Opening(OpenUni), Idle(SendStream), Sending(SendStream, Bytes), @@ -124,13 +123,10 @@ impl Future for SendUni { let is_empty = self.data.is_empty(); loop { match self.state { - SendUniState::New(ref mut c) => { + SendUniState::Opening(ref mut o) => { if is_empty { return Poll::Ready(Ok(())); } - self.state = SendUniState::Opening(c.open_uni()); - } - SendUniState::Opening(ref mut o) => { let send = ready!(Pin::new(o).poll(cx))?; self.state = SendUniState::Sending(send, self.ty.encoded()); }