From 6d80bd454ed4ec69b17e6a467f50be480ec13bb2 Mon Sep 17 00:00:00 2001 From: Michael Beaumont Date: Mon, 17 Aug 2020 21:19:44 +0200 Subject: [PATCH] Fix handling Streams.refs in `next_incoming` `Streams.inner.ref` doesn't need to be incremented if we don't return an `OpaqueStreamRef`. This prevented the bug in `send_push_promise` from appearing in the tests. --- src/proto/streams/streams.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/proto/streams/streams.rs b/src/proto/streams/streams.rs index 26eabbe..b97035a 100644 --- a/src/proto/streams/streams.rs +++ b/src/proto/streams/streams.rs @@ -557,17 +557,16 @@ where pub fn next_incoming(&mut self) -> Option> { let mut me = self.inner.lock().unwrap(); let me = &mut *me; - let key = me.actions.recv.next_incoming(&mut me.store); - // TODO: ideally, OpaqueStreamRefs::new would do this, but we're holding - // the lock, so it can't. - me.refs += 1; - key.map(|key| { + me.actions.recv.next_incoming(&mut me.store).map(|key| { let stream = &mut me.store.resolve(key); tracing::trace!( "next_incoming; id={:?}, state={:?}", stream.id, stream.state ); + // TODO: ideally, OpaqueStreamRefs::new would do this, but we're holding + // the lock, so it can't. + me.refs += 1; StreamRef { opaque: OpaqueStreamRef::new(self.inner.clone(), stream), send_buffer: self.send_buffer.clone(),