Skip to content

Commit

Permalink
fix: Resolve future polling type mismatches in connection handler
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Dec 26, 2024
1 parent eac013f commit 6b7ccbe
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions crates/core/src/transport/connection_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,10 @@ impl<S: Socket> UdpPacketsListener<S> {
let span = tracing::span!(tracing::Level::DEBUG, "gateway_connection");
async move {
let future = Box::pin(gw_ongoing_connection);
match futures::Future::poll(Pin::new(&future), &mut std::task::Context::from_waker(futures::task::noop_waker_ref())) {
Ok(result) => Ok(result),
Err(error) => Err((error, remote_addr))
match futures::Future::poll(unsafe { Pin::new_unchecked(&mut future) }, &mut std::task::Context::from_waker(futures::task::noop_waker_ref())) {
std::task::Poll::Ready(Ok(result)) => Ok(result),
std::task::Poll::Ready(Err(error)) => Err((error, remote_addr)),
std::task::Poll::Pending => Ok(result)
}
}
.instrument(span)
Expand Down Expand Up @@ -383,9 +384,10 @@ impl<S: Socket> UdpPacketsListener<S> {
let span = span!(tracing::Level::DEBUG, "traverse_nat");
async move {
let future = Box::pin(ongoing_connection);
match futures::Future::poll(Pin::new(&future), &mut std::task::Context::from_waker(futures::task::noop_waker_ref())) {
Ok(result) => Ok(result),
Err(error) => Err((error, remote_addr))
match futures::Future::poll(unsafe { Pin::new_unchecked(&mut future) }, &mut std::task::Context::from_waker(futures::task::noop_waker_ref())) {
std::task::Poll::Ready(Ok(result)) => Ok(result),
std::task::Poll::Ready(Err(error)) => Err((error, remote_addr)),
std::task::Poll::Pending => Ok(result)
}
}
.instrument(span)
Expand Down

0 comments on commit 6b7ccbe

Please sign in to comment.