Zebra/zebra-network/src
Janito Vaqueiro Ferreira Filho 1010773b05
Keep track of background peer tasks (#3253)
* Refactor to create heartbeat sender function

Move the code that's part of the heartbeat task into a separate helper
function.

* Move `Client` initialization down

Keep it closer to where it's actually used, and make it easier to add
new fields to `Client` for the connection and heartbeat tasks.

* Add background task handles to `Client` type

Prepare it to be able to check for panics or errors from the background
tasks.

* Add dummy background tasks to `ClientTestHarness`

Spawn simple timeout tasks as mock connection and heartbeat tasks.

* Fix `PeerSet` tests that use `ClientTestHarness`

Building a `ClientTestHarness` requires a Tokio runtime to be set up, so
the calls were moved into the `async` block.

* Refactor to create `set_task_exited_error`

Make the code reusable for both background tasks.

* Check heartbeat task for errors

Periodically poll it to check if the task has unexpectedly stopped.

* Check if connection background task has stopped

The client service should stop if the connection background task has
exited, because then it's not able to receive any replies.

* Allow aborting mocked `Client` background tasks

Wrap the background tasks in `Abortable`, so that they can be aborted
through the `ClientTestHarness`.

* Test if stopped connection task is detected

Check that stopping the background connection task is something that the
`Client` instance detects and handles correctly.

* Test if stopped heartbeat task is detected

Check that stopping the background heartbeat task is something that the
`Client` instance detects and handles correctly.

* Allow setting custom background tasks

Will be used later to create background tasks that panic.

* Test if `Client` handles panics in connection task

Use a mock background connection task that panics immediately, and check
that the `Client` handles it gracefully.

* Test if `Client` handles panics in heartbeat task

Use a mock background heartbeat task that panics immediately, and check
that the `Client` handles it gracefully.

* Change ticket referenced by `TODO`

The previously linked issue was a broad plan to improve Zebra's shutdown
behavior, while the new issue is more specific, and can be scheduled
sooner.

Co-authored-by: teor <teor@riseup.net>

Co-authored-by: teor <teor@riseup.net>
2021-12-22 01:35:38 +00:00
..
address_book Security: Limit address book size to limit memory usage (#3162) 2021-12-06 16:09:10 -03:00
config Use the default port for configured listen addresses with no port (#2043) 2021-04-21 23:14:29 +00:00
meta_addr Fix new clippy lints in clippy nightly (#3176) 2021-12-09 14:19:14 +00:00
peer Keep track of background peer tasks (#3253) 2021-12-22 01:35:38 +00:00
peer_set Keep track of background peer tasks (#3253) 2021-12-22 01:35:38 +00:00
protocol Add diagnostics for peer set hangs (#3203) 2021-12-14 21:11:03 +00:00
address_book.rs Avoid deadlocks in the address book mutex (#3244) 2021-12-20 00:44:43 +00:00
address_book_updater.rs Avoid deadlocks in the address book mutex (#3244) 2021-12-20 00:44:43 +00:00
config.rs Fix task handling bugs, so peers are more likely to be available (#3191) 2021-12-20 09:02:31 +10:00
constants.rs Release Zebra v1.0.0-beta.3 (#3256) 2021-12-21 19:42:39 -03:00
isolated.rs Refactor addr v1 serialization using a separate AddrV1 type (#3021) 2021-11-10 06:47:50 +10:00
lib.rs Fix task handling bugs, so peers are more likely to be available (#3191) 2021-12-20 09:02:31 +10:00
meta_addr.rs Stop doing thousands of time checks each time we connect to a peer (#3106) 2021-12-03 15:09:43 -03:00
peer.rs Keep track of background peer tasks (#3253) 2021-12-22 01:35:38 +00:00
peer_set.rs Track the number of active inbound and outbound peer connections (#2912) 2021-10-21 21:36:42 +00:00
policies.rs Fix task handling bugs, so peers are more likely to be available (#3191) 2021-12-20 09:02:31 +10:00
protocol.rs Refactor protocol into internal, external modules. 2019-11-27 05:06:01 -05:00