Fix some flow control bugs. (#152)
* Release stream capacity back to the connection to avoid capacity leaks. * Actually notify waiting tasks when capacity becomes available.
This commit is contained in:
		| @@ -229,8 +229,12 @@ where | ||||
|         self.send_capacity_inc = true; | ||||
|         self.send_flow.assign_capacity(capacity); | ||||
|  | ||||
|         trace!("  assigned capacity to stream; available={}; buffered={}; id={:?}", | ||||
|                self.send_flow.available(), self.buffered_send_data, self.id); | ||||
|  | ||||
|         // Only notify if the capacity exceeds the amount of buffered data | ||||
|         if self.send_flow.available() > self.buffered_send_data { | ||||
|             trace!("  notifying task"); | ||||
|             self.notify_send(); | ||||
|         } | ||||
|     } | ||||
| @@ -263,6 +267,10 @@ where | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub fn wait_send(&mut self) { | ||||
|         self.send_task = Some(task::current()); | ||||
|     } | ||||
|  | ||||
|     pub fn notify_recv(&mut self) { | ||||
|         if let Some(task) = self.recv_task.take() { | ||||
|             task.notify(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user