Skip to content

Provide remote: SocketAddr in create_io_poller #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: iroh-0.11.x
Choose a base branch
from
Draft
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
8 changes: 6 additions & 2 deletions quinn/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ impl ConnectionRef {
socket: Arc<dyn AsyncUdpSocket>,
runtime: Arc<dyn Runtime>,
) -> Self {
let remote = conn.remote_address();
Self(Arc::new(ConnectionInner {
state: Mutex::new(State {
inner: conn,
Expand All @@ -897,7 +898,7 @@ impl ConnectionRef {
stopped: FxHashMap::default(),
error: None,
ref_count: 0,
io_poller: socket.clone().create_io_poller(),
io_poller: socket.clone().create_io_poller(remote),
socket,
runtime,
send_buffer: Vec::new(),
Expand Down Expand Up @@ -1110,7 +1111,10 @@ impl State {
match self.conn_events.poll_recv(cx) {
Poll::Ready(Some(ConnectionEvent::Rebind(socket))) => {
self.socket = socket;
self.io_poller = self.socket.clone().create_io_poller();
self.io_poller = self
.socket
.clone()
.create_io_poller(self.inner.remote_address());
self.inner.local_address_changed();
}
Poll::Ready(Some(ConnectionEvent::Proto(event))) => {
Expand Down
2 changes: 1 addition & 1 deletion quinn/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub trait AsyncUdpSocket: Send + Sync + Debug + 'static {
/// [`Waker`].
///
/// [`Waker`]: std::task::Waker
fn create_io_poller(self: Arc<Self>) -> Pin<Box<dyn UdpPoller>>;
fn create_io_poller(self: Arc<Self>, remote: SocketAddr) -> Pin<Box<dyn UdpPoller>>;

/// Send UDP datagrams from `transmits`, or return `WouldBlock` and clear the underlying
/// socket's readiness, or return an I/O error
Expand Down
5 changes: 4 additions & 1 deletion quinn/src/runtime/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ impl UdpSocket {
}

impl AsyncUdpSocket for UdpSocket {
fn create_io_poller(self: Arc<Self>) -> Pin<Box<dyn super::UdpPoller>> {
fn create_io_poller(
self: Arc<Self>,
_remote: std::net::SocketAddr,
) -> Pin<Box<dyn super::UdpPoller>> {
Box::pin(UdpPollHelper::new(move || {
let socket = self.clone();
async move { socket.io.writable().await }
Expand Down
3 changes: 2 additions & 1 deletion quinn/src/runtime/tokio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{
future::Future,
io,
net::SocketAddr,
pin::Pin,
sync::Arc,
task::{Context, Poll},
Expand Down Expand Up @@ -55,7 +56,7 @@ struct UdpSocket {
}

impl AsyncUdpSocket for UdpSocket {
fn create_io_poller(self: Arc<Self>) -> Pin<Box<dyn super::UdpPoller>> {
fn create_io_poller(self: Arc<Self>, _remote: SocketAddr) -> Pin<Box<dyn super::UdpPoller>> {
Box::pin(UdpPollHelper::new(move || {
let socket = self.clone();
async move { socket.io.writable().await }
Expand Down
Loading