Make SendStream::poll_capacity never return Ok(Some(0)) (#596)
Fixes #270
This commit is contained in:
@@ -32,6 +32,7 @@ pub async fn yield_once() {
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Should only be called after a non-0 capacity was requested for the stream.
|
||||
pub fn wait_for_capacity(stream: h2::SendStream<Bytes>, target: usize) -> WaitForCapacity {
|
||||
WaitForCapacity {
|
||||
stream: Some(stream),
|
||||
@@ -59,6 +60,11 @@ impl Future for WaitForCapacity {
|
||||
|
||||
let act = self.stream().capacity();
|
||||
|
||||
// If a non-0 capacity was requested for the stream before calling
|
||||
// wait_for_capacity, then poll_capacity should return Pending
|
||||
// until there is a non-0 capacity.
|
||||
assert_ne!(act, 0);
|
||||
|
||||
if act >= self.target {
|
||||
return Poll::Ready(self.stream.take().unwrap().into());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user