-
Notifications
You must be signed in to change notification settings - Fork 165
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
ref(netcheck): make netcheck a long-running actor #1028
Conversation
This is very much WIP, but shows how the netcheck can be a long-running actor. Much cleanup needed.
src/hp/netcheck.rs
Outdated
self.current_check_run.take(); | ||
} | ||
ActorMessage::StunPacket { payload, from_addr } => { | ||
// TODO: drop package if no check is running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, first thing in the handle function does exactly that
let skip_external = self.skip_external_network; | ||
let resolver = self.dns_resolver.clone(); // not a cheap clone, maybe Arc it | ||
let addr = self.addr(); | ||
tokio::spawn(async move { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to track this task, and make sure it gets aborted on drop as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was wondering about that as well. But kind of wanted to defer that to a followup PR. Created #1037 for this as there's a few options to consider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some small nits, otherwise looks great
This turns the netcheck into a long running actor:
Client
creates the actor which runs in a background tokio task.Client
can be cloned to get more handles to the netcheck actor.Client
is dropped the actor is stopped.This last point is the motivation, it simplifies how things are wired up and makes it easier to keep the right state in the netcheck actor where it belongs. This will also make future changes to netcheck more contained.
It turns the former netcheck actor into more of a full-scale actor. The
ReportState
is not following this pattern yet.