Commit 30c23e8
authored
fix: stop relay actor on endpoint close (#3601)
## Description
Since the transport abstraction was introduced, we no longer shut down
the relay actor when calling `Endpoint::close`. The relay actor is
currently only stopped when the last clone of the `iroh::Endpoint` is
dropped. This is surprising and wasteful. This PR fixes this so that the
relay actor is stopped when calling `Endpoint::close`.
Background: Since introducing the transport abstraction, the relay actor
handle is now owned by `Transports` which is owned by `MagicUdpSocket`
which is owned by the `quinn::Endpoint` as its `AsyncUdpSocket`. The
`AsyncUdpSocket` trait has no notification when the endpoint is closing,
thus currently the relay transport (and the relay actor, which it owns)
is not notified at all when the endpoint is shutting down. Therefore, it
keeps running (and potentially reconnecting to the relay or receiving
messages) until it is stopped when the last clone of the endpoint is
dropped and thus the `AbortOnDropHandle` owning the relay actor tasks is
dropped, finally stopping the relay actor tasks.
This PR exposes an existing cancellation token within the relay actor to
the magicsocket, allowing it to cancel the relay actors when calling
`Endpoint::close`.
## Breaking Changes
<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->
## Notes & open questions
I tested this by looking at logs after closing an endpoint. Not sure if
there is a good way to test this. I'd vote to merge this even without a
test because it fixes an issue, unless someone has a good idea on how to
test this.
## Change checklist
<!-- Remove any that are not relevant. -->
- [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.
- [ ] Tests if relevant.
- [x] All breaking changes documented.
- [ ] List all breaking changes in the above "Breaking Changes" section.
- [ ] Open an issue or PR on any number0 repos that are affected by this
breaking change. Give guidance on how the updates should be handled or
do the actual updates themselves. The major ones are:
- [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc)
- [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip)
- [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs)
- [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe)
- [ ] [`sendme`](https://github.com/n0-computer/sendme)1 parent 7b9c95b commit 30c23e8
File tree
3 files changed
+25
-23
lines changed- iroh/src
- magicsock/transports
- relay
3 files changed
+25
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
153 | | - | |
| 152 | + | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
1392 | 1392 | | |
1393 | 1393 | | |
1394 | 1394 | | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
1399 | | - | |
1400 | | - | |
1401 | | - | |
1402 | | - | |
1403 | | - | |
1404 | | - | |
1405 | | - | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
1406 | 1411 | | |
1407 | 1412 | | |
1408 | 1413 | | |
| |||
1531 | 1536 | | |
1532 | 1537 | | |
1533 | 1538 | | |
1534 | | - | |
1535 | | - | |
1536 | | - | |
1537 | 1539 | | |
1538 | 1540 | | |
1539 | | - | |
| 1541 | + | |
1540 | 1542 | | |
1541 | 1543 | | |
1542 | 1544 | | |
| |||
1546 | 1548 | | |
1547 | 1549 | | |
1548 | 1550 | | |
1549 | | - | |
| 1551 | + | |
1550 | 1552 | | |
1551 | 1553 | | |
1552 | 1554 | | |
| |||
1587 | 1589 | | |
1588 | 1590 | | |
1589 | 1591 | | |
1590 | | - | |
| 1592 | + | |
1591 | 1593 | | |
1592 | 1594 | | |
1593 | 1595 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
855 | 855 | | |
856 | 856 | | |
857 | 857 | | |
| 858 | + | |
858 | 859 | | |
859 | | - | |
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
| |||
0 commit comments