Skip to content
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

remove signaling channels from listeners once used #857

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions plane/src/proxy/route_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ impl RouteMap {
.lock()
.expect("Routes lock was poisoned.")
.push(token.clone(), route_info);
let listener_lock = self.listeners.lock().expect("Listeners lock was poisoned.");
if let Some(listener_lock) = listener_lock.get(&token) {
let mut listener_lock = self.listeners.lock().expect("Listeners lock was poisoned.");
if let Some(channel) = listener_lock.get(&token) {
// We are just using the watch channel as a signal; this will ensure that anyone listening on `.changed()` resolves.
listener_lock.send_modify(|()| ());
channel.send_modify(|()| ());
listener_lock.remove(&token);
};
}

Expand All @@ -119,7 +120,7 @@ impl RouteMap {
pub fn remove_backend(&self, backend: &BackendName) {
// When a backend is terminated, we invalidate all routes that point to it.
// We do this by looping over the connection tokens, but this is relatively inexpensive
// because we have a maximum of 1,000 connection tokens in the LRU cache.
// because we have a maximum of <CACHE_SIZE> connection tokens in the LRU cache.
let mut count = 0;
let mut lock = self.routes.lock().expect("Routes lock was poisoned.");
for (_, maybe_route_info) in lock.iter_mut() {
Expand Down
Loading