Remove the session only if its `session_id` matches the one we are cleaning up. Returns `true` if the entry was removed. This guards against the supersede race: an old session's task may finish long after a new session has taken its place. The old task's cleanup must not evict the new registration.
(&self, sandbox_id: &str, session_id: &str)
| 155 | /// finish long after a new session has taken its place. The old task's |
| 156 | /// cleanup must not evict the new registration. |
| 157 | fn remove_if_current(&self, sandbox_id: &str, session_id: &str) -> bool { |
| 158 | let mut sessions = self.sessions.lock().unwrap(); |
| 159 | let is_current = sessions |
| 160 | .get(sandbox_id) |
| 161 | .is_some_and(|s| s.session_id == session_id); |
| 162 | if is_current { |
| 163 | sessions.remove(sandbox_id); |
| 164 | } |
| 165 | is_current |
| 166 | } |
| 167 | |
| 168 | /// Look up the sender for a supervisor session, waiting up to `timeout` |
| 169 | /// for it to appear if absent. |
no test coverage detected