Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: read the pause flag under the pause lock

Richie McIlroy5569b930775d
diff --git a/crates/recording/src/output_pipeline/core.rs b/crates/recording/src/output_pipeline/core.rs
index 55537921b..dee920e3d 100644
--- a/crates/recording/src/output_pipeline/core.rs
+++ b/crates/recording/src/output_pipeline/core.rs
@@ -2167,11 +2167,13 @@ impl SharedWallClockPause {
}
pub fn check(&self) -> (bool, Duration) {
- let is_paused = self.flag.load(Ordering::Acquire);
let mut inner = match self.inner.lock() {
Ok(guard) => guard,
Err(poisoned) => poisoned.into_inner(),
};
+ // Read under the lock `set_paused_at` holds while it updates both,
+ // so a stale flag cannot end a pause it just started.
+ let is_paused = self.flag.load(Ordering::Acquire);
if is_paused {
if inner.pause_started_at.is_none() {