Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ clap = { version = "4.6.7", features = ["derive"] }
divan = "0.1.21"
ed25519-dalek = "3.0.0"
getrandom = "0.4.3"
parking_lot = "0.13.0"
reflink-copy = "0.1.30"
# Only in origin-platform. The version and features reflink-copy uses on Linux.
rustix = { version = "1.1.6", default-features = false, features = ["fs", "std"] }
Expand Down
1 change: 1 addition & 0 deletions apps/origin-src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ clap.workspace = true
getrandom.workspace = true
origin-platform.workspace = true
origin-shared.workspace = true
parking_lot.workspace = true
serde.workspace = true
similar.workspace = true
thiserror.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions apps/origin-src/src/queue/tests/changes.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Tests for landing changes: rebasing, stacks, who may land, and keeping a
//! landing that waits.

use std::sync::Mutex;
use std::thread;

use origin_shared::{Statement, Verdict};
use parking_lot::Mutex;

use super::*;

Expand Down Expand Up @@ -145,12 +145,12 @@ fn concurrent_landings_serialize() {
scope.spawn(move || {
for &change in chunk {
assert!(matches!(repo.land(change)[..], [Landing::Landed { .. }]));
*landed.lock().unwrap() += 1;
*landed.lock() += 1;
}
});
}
});
assert_eq!(*landed.lock().unwrap(), changes.len());
assert_eq!(*landed.lock(), changes.len());
let log = repo.store.log(&TargetName::MAIN).unwrap();
assert_eq!(log.len(), changes.len() + 1);
for pair in log.windows(2) {
Expand Down
10 changes: 4 additions & 6 deletions apps/origin-src/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet};
use std::path::PathBuf;
use std::sync::{Arc, Condvar, Mutex, MutexGuard, PoisonError};
use std::sync::Arc;

use origin_platform::Native;
use origin_shared::api::{
Expand All @@ -30,6 +30,7 @@ use origin_shared::{
Base, ChangeId, Head, NodeKey, Object, ObjectId, ObjectKind, Principal, PrincipalName,
RecordId, Statement, StatementId, TargetName,
};
use parking_lot::{Condvar, Mutex, MutexGuard};

use crate::annotations::{AnnotateError, Annotations};
use crate::index::Index;
Expand Down Expand Up @@ -519,10 +520,7 @@ impl Indexes {
fn take(&self, most: usize) -> Taken<'_> {
let mut state = self.state();
while state.kept.is_empty() && state.taken >= most {
state = self
.returned
.wait(state)
.unwrap_or_else(PoisonError::into_inner);
self.returned.wait(&mut state);
}
state.taken += 1;
Taken {
Expand All @@ -532,7 +530,7 @@ impl Indexes {
}

fn state(&self) -> MutexGuard<'_, IndexesState> {
self.state.lock().unwrap_or_else(PoisonError::into_inner)
self.state.lock()
}
}

Expand Down
34 changes: 13 additions & 21 deletions apps/origin-src/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ use std::io;
use std::num::NonZero;
use std::panic;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, PoisonError};
use std::sync::Arc;
use std::thread;
use std::time::{Duration, SystemTime};

use origin_platform::{DurableWrite, LockMode, LockedFile, Native, Platform, WritableError};
use origin_shared::object::{DecodeError, IdMismatch};
use origin_shared::{EncodedObject, Head, ObjectId, TargetName, TypedId};
use parking_lot::Mutex;

use crate::index::Entry;
use crate::oplog::{Actor, Effect};
Expand Down Expand Up @@ -528,10 +529,7 @@ impl<P: Platform> Batch<'_, P> {
.map_err(|source| StoreError::io(&path, source))?;
self.write.stage(path, &compressed)?;
if let Some(entry) = entry {
self.entries
.lock()
.unwrap_or_else(PoisonError::into_inner)
.push(entry);
self.entries.lock().push(entry);
}
Ok(true)
}
Expand Down Expand Up @@ -576,10 +574,7 @@ impl<P: Platform> Batch<'_, P> {
/// collection may have rewritten a pack without the object, and a writer
/// must never skip an object that is gone.
fn packed(&self, id: ObjectId) -> Result<bool, StoreError> {
let mut read = self
.manifest_read
.lock()
.unwrap_or_else(PoisonError::into_inner);
let mut read = self.manifest_read.lock();
if !*read {
self.store.reload_packs()?;
*read = true;
Expand All @@ -605,10 +600,7 @@ impl<P: Platform> Batch<'_, P> {
/// Fails if an object cannot be renamed into place, a directory cannot be
/// synced, or the op log cannot be appended to.
pub fn commit(self) -> Result<(), StoreError> {
let entries = self
.entries
.into_inner()
.unwrap_or_else(PoisonError::into_inner);
let entries = self.entries.into_inner();
if entries.is_empty() {
return Ok(self.write.commit()?);
}
Expand Down Expand Up @@ -711,9 +703,9 @@ impl StoreError {
pub(crate) mod tests {
use std::fs::File;
use std::slice;
use std::sync::Mutex;

use origin_platform::{CloneFile, Durability, Error, FileLock, FileSystem, FsKind, ReadAt};
use parking_lot::Mutex;

use origin_shared::{Record, Tree, TreeId};

Expand All @@ -739,18 +731,18 @@ pub(crate) mod tests {

impl Durability for Recorder {
fn sync_file(&self, file: &File) -> io::Result<()> {
self.0.lock().unwrap().push(Synced::File);
self.0.lock().push(Synced::File);
Native::default().sync_file(file)
}

fn sync_dir(&self, dir: &Path) -> io::Result<()> {
self.0.lock().unwrap().push(Synced::Dir(dir.to_owned()));
self.0.lock().push(Synced::Dir(dir.to_owned()));
Native::default().sync_dir(dir)
}

fn sync_batch<'f>(&self, files: impl IntoIterator<Item = &'f Path>) -> Result<(), Error> {
let files: Vec<_> = files.into_iter().collect();
self.0.lock().unwrap().push(Synced::Batch(files.len()));
self.0.lock().push(Synced::Batch(files.len()));
Native::default().sync_batch(files)
}
}
Expand Down Expand Up @@ -778,13 +770,13 @@ pub(crate) mod tests {
store.init().unwrap();
let blob = EncodedObject::blob(b"hello");
store.write_all(slice::from_ref(&blob)).unwrap();
store.platform.0.lock().unwrap().clear();
store.platform.0.lock().clear();

// Its writer may not have synced it yet, if another one wrote it.
assert_eq!(store.write_all(slice::from_ref(&blob)).unwrap(), 0);
let shard = store.path(blob.id()).parent().unwrap().to_owned();
assert_eq!(
store.platform.0.into_inner().unwrap(),
store.platform.0.into_inner(),
[Synced::Batch(0), Synced::Dir(shard)]
);
}
Expand All @@ -796,15 +788,15 @@ pub(crate) mod tests {
store.init().unwrap();
let blob = EncodedObject::blob(b"hello");
store.write_all(slice::from_ref(&blob)).unwrap();
store.platform.0.lock().unwrap().clear();
store.platform.0.lock().clear();

let batch = store.batch();
assert!(batch.depend(blob.id()).unwrap());
assert!(!batch.depend(EncodedObject::blob(b"absent").id()).unwrap());
batch.commit().unwrap();
let shard = store.path(blob.id()).parent().unwrap().to_owned();
assert_eq!(
store.platform.0.into_inner().unwrap(),
store.platform.0.into_inner(),
[Synced::Batch(0), Synced::Dir(shard)]
);
}
Expand Down
Loading
Loading