Skip to content

Commit

Permalink
refactor(iroh): Rename the relay-is-ready-to-send waker (#3014)
Browse files Browse the repository at this point in the history
## Description

I thought I was going to put in a queue or channel of some sort... but
not yet.  Still, let's rename this for now.

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
  • Loading branch information
flub authored Dec 5, 2024
1 parent c5d9e68 commit 79bf3c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions iroh/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,11 @@ pub(crate) struct MagicSock {
/// [`AsyncUdpSocket`]. This queue takes care of the wakers needed by
/// [`AsyncUdpSocket::poll_recv`].
relay_datagrams_queue: Arc<RelayDatagramsQueue>,

network_send_wakers: Arc<parking_lot::Mutex<Option<Waker>>>,
/// Waker to wake the [`AsyncUdpSocket`] when more data can be sent to the relay server.
///
/// This waker is used by [`IoPoller`] and the [`RelayActor`] to signal when more
/// datagrams can be sent to the relays.
relay_send_waker: Arc<parking_lot::Mutex<Option<Waker>>>,
/// Counter for ordering of [`MagicSock::poll_recv`] polling order.
poll_recv_counter: AtomicUsize,

Expand Down Expand Up @@ -453,7 +456,7 @@ impl MagicSock {
ipv4_poller,
ipv6_poller,
relay_sender,
relay_send_waker: self.network_send_wakers.clone(),
relay_send_waker: self.relay_send_waker.clone(),
})
}

Expand Down Expand Up @@ -1549,7 +1552,7 @@ impl Handle {
closing: AtomicBool::new(false),
closed: AtomicBool::new(false),
relay_datagrams_queue: relay_datagrams_queue.clone(),
network_send_wakers: Arc::new(parking_lot::Mutex::new(None)),
relay_send_waker: Arc::new(parking_lot::Mutex::new(None)),
poll_recv_counter: AtomicUsize::new(0),
actor_sender: actor_sender.clone(),
ipv6_reported: Arc::new(AtomicBool::new(false)),
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/magicsock/relay_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ impl RelayActor {
}

// Wake up the send waker if one is waiting for space in the channel
let mut wakers = self.msock.network_send_wakers.lock();
let mut wakers = self.msock.relay_send_waker.lock();
if let Some(waker) = wakers.take() {
waker.wake();
}
Expand Down

0 comments on commit 79bf3c3

Please sign in to comment.