From 1a9af1eb760d7191f32dec3db0522e2184d3656a Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 15 Nov 2026 23:35:02 +0000 Subject: store: the policy's reading unmarked however it ends `signs_values` marks, for its thread, that the policy is being read, so that the reading doesn't ask itself again; a panic within it left the mark, and that thread read every strict place by Automerge's order from then on. The mark is now taken off when the reading returns or unwinds. --- src/document/store.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/document') diff --git a/src/document/store.rs b/src/document/store.rs index 8da6270..cd455b6 100644 --- a/src/document/store.rs +++ b/src/document/store.rs @@ -234,13 +234,19 @@ fn signs_values(doc: &impl ReadDoc) -> bool { thread_local! { static READING: std::cell::Cell = const { std::cell::Cell::new(false) }; } + // Unset when this returns, or unwinds. + struct Reading; + impl Drop for Reading { + fn drop(&mut self) { + READING.set(false); + } + } if READING.get() { return false; } READING.set(true); - let strict = crate::access::policy::of(doc).strict(); - READING.set(false); - strict + let _reading = Reading; + crate::access::policy::of(doc).strict() } /// Whether the values at `key` of `parents` are ordered by `seq`: at the policy's place, -- cgit v1.3.1