Skip to content

Commit

Permalink
fix: avoid unwrapping for the Future impl of UpgradeableConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
DDtKey committed Apr 10, 2024
1 parent 203d1b0 commit 785c8cc
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/server/conn/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,18 @@ where
type Output = crate::Result<()>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match ready!(Pin::new(&mut self.inner.as_mut().unwrap().conn).poll(cx)) {
Ok(proto::Dispatched::Shutdown) => Poll::Ready(Ok(())),
Ok(proto::Dispatched::Upgrade(pending)) => {
let (io, buf, _) = self.inner.take().unwrap().conn.into_inner();
pending.fulfill(Upgraded::new(io, buf));
Poll::Ready(Ok(()))
if let Some(conn) = self.inner.as_mut() {
match ready!(Pin::new(&mut conn.conn).poll(cx)) {
Ok(proto::Dispatched::Shutdown) => Poll::Ready(Ok(())),
Ok(proto::Dispatched::Upgrade(pending)) => {
let (io, buf, _) = self.inner.take().unwrap().conn.into_inner();
pending.fulfill(Upgraded::new(io, buf));
Poll::Ready(Ok(()))
}
Err(e) => Poll::Ready(Err(e)),
}
Err(e) => Poll::Ready(Err(e)),
} else {
Poll::Ready(Ok(()))
}
}
}

0 comments on commit 785c8cc

Please sign in to comment.