Skip to content

Commit 401cc43

Browse files
[sim] handle missing object in sim_force_remove (same race as sim_poke)
1 parent 4838053 commit 401cc43

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

sled-agent/src/sim/collection.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,13 @@ impl<S: Simulatable + 'static> SimCollection<S> {
221221
/// any further state changes for it.
222222
pub async fn sim_force_remove(&self, id: Uuid) {
223223
let mut objects = self.objects.lock().await;
224-
let object = objects.remove(&id).unwrap();
224+
// The object may already have been destroyed and removed by a
225+
// concurrent `sim_poke` (e.g., a background `sim_step` racing with
226+
// an explicit `instance_unregister`). In that case there is
227+
// nothing left to do.
228+
let Some(object) = objects.remove(&id) else {
229+
return;
230+
};
225231
if let Some(mut tx) = object.channel_tx {
226232
tx.close_channel();
227233
}

0 commit comments

Comments
 (0)