Skip to content

Refactor many get_zone instances away#517

Open
tertsdiepraam wants to merge 10 commits intomainfrom
less-get-zone
Open

Refactor many get_zone instances away#517
tertsdiepraam wants to merge 10 commits intomainfrom
less-get-zone

Conversation

@tertsdiepraam
Copy link
Contributor

@tertsdiepraam tertsdiepraam commented Mar 10, 2026

This should reduce the possibility for deadlocks a bit and reduces the contention on the center.state mutex.

Some calls are just move from the callee to the caller, because then they happen more at the "edge". For example, the http server now does more of these calls because it needs to translate the names from the API to actual zones and it makes sense to do that there.

Builds on #504 but doesn't merge into it because I think that shouldn't be merged directly.

Copy link
Contributor

@bal-e bal-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Comment on lines +1000 to +1002
let state = &center.state.lock().unwrap();
let now = SystemTime::now();
for zone in zone_tree.load().iter_zones() {
let zone_name = zone.apex_name();
for zone in &state.zones {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe clone out state.zones so you don't hold the lock for very long?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Also I see you added a get_zone below that I can remove as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash if NOTIFY received for non-existing zone.

3 participants