From 0a6fddfd8f7bff2def58fb410afb27b2359e8990 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 14 Dec 2022 14:15:47 +0100 Subject: [PATCH 1/3] Fix panic message --- crates/fj-kernel/src/partial/wrapper.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/wrapper.rs b/crates/fj-kernel/src/partial/wrapper.rs index d855d3cb3..e0e148529 100644 --- a/crates/fj-kernel/src/partial/wrapper.rs +++ b/crates/fj-kernel/src/partial/wrapper.rs @@ -174,7 +174,7 @@ impl Inner { fn write(&self) -> RwLockWriteGuard> { self.0 .try_write() - .expect("Tried to modify `Partial` that is already being modified") + .expect("Tried to modify `Partial` that is currently locked") } } From 4bc940d8c4fdccb218fe117cf321cd225a7f015e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 14 Dec 2022 14:17:19 +0100 Subject: [PATCH 2/3] Prevent deadlock due to programmer error --- crates/fj-kernel/src/partial/wrapper.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/wrapper.rs b/crates/fj-kernel/src/partial/wrapper.rs index e0e148529..10813e4ff 100644 --- a/crates/fj-kernel/src/partial/wrapper.rs +++ b/crates/fj-kernel/src/partial/wrapper.rs @@ -168,7 +168,9 @@ impl Inner { } fn read(&self) -> RwLockReadGuard> { - self.0.read() + self.0 + .try_read() + .expect("Tried to read `Partial` that is currently being modified") } fn write(&self) -> RwLockWriteGuard> { From 2d0ecd8ff6a71a435215026d0f96001ef4834314 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 14 Dec 2022 14:18:20 +0100 Subject: [PATCH 3/3] Update documentation of `Partial` --- crates/fj-kernel/src/partial/wrapper.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/partial/wrapper.rs b/crates/fj-kernel/src/partial/wrapper.rs index 10813e4ff..5effa6bb3 100644 --- a/crates/fj-kernel/src/partial/wrapper.rs +++ b/crates/fj-kernel/src/partial/wrapper.rs @@ -76,7 +76,7 @@ impl Partial { /// # Panics /// /// Panics, if this method is called while the return value from a previous - /// call is still borrowed. + /// call to this method of [`Self::read`] is still borrowed. pub fn write(&mut self) -> impl DerefMut + '_ { let mut inner = self.inner.write(); @@ -91,7 +91,7 @@ impl Partial { /// /// # Panics /// - /// Panics, if a return value of [`Self::write`] is still borrowed. + /// Panics, if a call to [`Self::write`] would panic. pub fn build(self, objects: &mut Service) -> Handle where T: Insert,