reset pending push promises if user drops all refs (#199)
This commit is contained in:
		| @@ -87,6 +87,7 @@ impl Prioritize { | ||||
|     pub fn schedule_send(&mut self, stream: &mut store::Ptr, task: &mut Option<Task>) { | ||||
|         // If the stream is waiting to be opened, nothing more to do. | ||||
|         if !stream.is_pending_open { | ||||
|             trace!("schedule_send; {:?}", stream.id); | ||||
|             // Queue the stream | ||||
|             self.pending_send.push(stream); | ||||
|  | ||||
|   | ||||
| @@ -615,6 +615,8 @@ impl Recv { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         trace!("enqueue_reset_expiration; {:?}", stream.id); | ||||
|  | ||||
|         if !counts.can_inc_num_reset_streams() { | ||||
|             // try to evict 1 stream if possible | ||||
|             // if max allow is 0, this won't be able to evict, | ||||
|   | ||||
| @@ -909,16 +909,29 @@ fn drop_stream_ref(inner: &Mutex<Inner>, key: store::Key) { | ||||
|  | ||||
|     let actions = &mut me.actions; | ||||
|  | ||||
|     me.counts.transition(stream, |counts, mut stream| { | ||||
|         if stream.is_canceled_interest() { | ||||
|             actions.send.schedule_cancel( | ||||
|                 &mut stream, | ||||
|                 &mut actions.task); | ||||
|             actions.recv.enqueue_reset_expiration(stream, counts); | ||||
|     me.counts.transition(stream, |counts, stream| { | ||||
|         maybe_cancel(stream, actions, counts); | ||||
|  | ||||
|         if stream.ref_count == 0 { | ||||
|             let mut ppp = stream.pending_push_promises.take(); | ||||
|             while let Some(promise) = ppp.pop(stream.store_mut()) { | ||||
|                 counts.transition(promise, |counts, stream| { | ||||
|                     maybe_cancel(stream, actions, counts); | ||||
|                 }); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
|  | ||||
| fn maybe_cancel(stream: &mut store::Ptr, actions: &mut Actions, counts: &mut Counts) { | ||||
|     if stream.is_canceled_interest() { | ||||
|         actions.send.schedule_cancel( | ||||
|             stream, | ||||
|             &mut actions.task); | ||||
|         actions.recv.enqueue_reset_expiration(stream, counts); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // ===== impl SendBuffer ===== | ||||
|  | ||||
| impl<B> SendBuffer<B> { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user