MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / remove_if_current

Method remove_if_current

crates/openshell-server/src/supervisor_session.rs:157–166  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 1

Calls 2

getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected