Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/client/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,11 @@ impl<T, U> Receiver<T, U> {
}
}

#[cfg(feature = "http1")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#4222 added poll_close while fixing the same h1 race condition from #4202.

It was gated to h1 because h1 was it's only caller.

this PR does the same race fix for h2.

ready!(self.req_rx.poll_close(cx));

ClientTask calls poll_close, and poll_close calls close.

If we keep these h1 gates, an "h2 only" build fails.

pub(crate) fn close(&mut self) {
self.taker.cancel();
self.inner.close();
}

#[cfg(feature = "http1")]
pub(crate) fn poll_close(&mut self, cx: &mut Context<'_>) -> Poll<()> {
self.close();
// A send that started before close may still be publishing its envelope.
Expand Down
20 changes: 20 additions & 0 deletions src/proto/h2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ where
h2_tx,
req_rx,
fut_ctx: None,
closing: None,
marker: PhantomData,
})
}
Expand Down Expand Up @@ -434,6 +435,7 @@ where
h2_tx: SendRequest<SendBuf<B::Data>>,
req_rx: ClientRx<B>,
fut_ctx: Option<FutCtx<B>>,
closing: Option<crate::Result<Dispatched>>,
marker: PhantomData<T>,
}

Expand Down Expand Up @@ -676,6 +678,24 @@ where
type Output = crate::Result<Dispatched>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
if self.closing.is_none() {
let res = ready!(self.poll_dispatch(cx));
self.closing = Some(res);
}
ready!(self.req_rx.poll_close(cx));
Poll::Ready(self.closing.take().expect("Future polled twice"))
}
}

impl<B, E, T> ClientTask<B, E, T>
where
B: Body + 'static + Unpin,
B::Data: Send,
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
E: Http2ClientConnExec<B, T> + Clone + Unpin,
T: Read + Write + Unpin,
{
fn poll_dispatch(&mut self, cx: &mut Context<'_>) -> Poll<crate::Result<Dispatched>> {
loop {
match ready!(self.h2_tx.poll_ready(cx)) {
Ok(()) => (),
Expand Down
Loading