Skip to content

Commit

Permalink
fix: check retiring workers more strictly
Browse files Browse the repository at this point in the history
(cherry picked from commit af8287f)
  • Loading branch information
nyannyacha committed Jan 10, 2024
1 parent 14f75b0 commit a0b5688
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/base/src/rt_worker/worker_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ impl WorkerPool {
}

pub fn add_user_worker(&mut self, key: Uuid, profile: UserWorkerProfile) {
// TODO: Check before insert
self.active_workers
.insert(profile.service_path.clone(), key);
self.user_workers.insert(key, profile);
Expand Down Expand Up @@ -172,7 +173,13 @@ impl WorkerPool {

pub fn retire(&mut self, key: &Uuid) {
if let Some(profile) = self.user_workers.get(key) {
self.active_workers.remove(&profile.service_path);
if self
.active_workers
.get(&profile.service_path)
.is_some_and(|it| it == key)
{
self.active_workers.remove(&profile.service_path);
}
}
}

Expand Down

0 comments on commit a0b5688

Please sign in to comment.