Skip to main content

update_registry

Function update_registry 

Source
pub fn update_registry<F>(modifier: F) -> Result<()>
where F: FnOnce(&mut SessionRegistry) -> Result<()>,
Expand description

v0.7.0-alpha.3: flock’d read-modify-write of the session registry.

write_registry alone is not safe under concurrency — multiple MCP processes auto-initing in parallel each read an old snapshot, mutate their copy, and write back, losing N-1 updates. This helper acquires an exclusive flock on a sibling lockfile, re-reads inside the lock, applies the caller’s modifier, writes atomically, and releases.

Modeled on config::update_relay_state. Lock contention is bounded: modifications are pure HashMap operations, write is whole-file at roughly the registry size (KBs, not MBs).