Skip to content

Commit 6d80bd4

Browse files
michaelbeaumontseanmonstar
authored andcommitted
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.
1 parent e3a358d commit 6d80bd4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/proto/streams/streams.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,17 +557,16 @@ where
557557
pub fn next_incoming(&mut self) -> Option<StreamRef<B>> {
558558
let mut me = self.inner.lock().unwrap();
559559
let me = &mut *me;
560-
let key = me.actions.recv.next_incoming(&mut me.store);
561-
// TODO: ideally, OpaqueStreamRefs::new would do this, but we're holding
562-
// the lock, so it can't.
563-
me.refs += 1;
564-
key.map(|key| {
560+
me.actions.recv.next_incoming(&mut me.store).map(|key| {
565561
let stream = &mut me.store.resolve(key);
566562
tracing::trace!(
567563
"next_incoming; id={:?}, state={:?}",
568564
stream.id,
569565
stream.state
570566
);
567+
// TODO: ideally, OpaqueStreamRefs::new would do this, but we're holding
568+
// the lock, so it can't.
569+
me.refs += 1;
571570
StreamRef {
572571
opaque: OpaqueStreamRef::new(self.inner.clone(), stream),
573572
send_buffer: self.send_buffer.clone(),

0 commit comments

Comments
 (0)