diff --git a/src/platform/redox/clone.rs b/src/platform/redox/clone.rs index 22d8e15053..c0f7414251 100644 --- a/src/platform/redox/clone.rs +++ b/src/platform/redox/clone.rs @@ -7,29 +7,7 @@ use syscall::{ SetSighandlerData, SIGCONT, }; -use crate::sync::rwlock::RwLock; - use redox_rt::{proc::FdGuard, signal::sighandler_function}; pub use redox_rt::proc::*; - -static CLONE_LOCK: RwLock = RwLock::new(crate::pthread::Pshared::Private); - -struct Guard; -impl Drop for Guard { - fn drop(&mut self) { - CLONE_LOCK.unlock() - } -} - -pub fn rdlock() -> impl Drop { - CLONE_LOCK.acquire_read_lock(None); - - Guard -} -pub fn wrlock() -> impl Drop { - CLONE_LOCK.acquire_write_lock(None); - - Guard -} pub use redox_rt::thread::*; diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index 2c6c2e9b3f..e684191bf4 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -15,6 +15,7 @@ use crate::{ c_str::{CStr, CString}, error::{self, Errno, Result, ResultExt}, fs::File, + sync::rwlock::RwLock, header::{ dirent::dirent, errno::{ @@ -75,6 +76,8 @@ macro_rules! path_from_c_str { use self::{exec::Executable, path::canonicalize}; +static CLONE_LOCK: RwLock<()> = RwLock::new(()); + /// Redox syscall implementation of the platform abstraction layer. pub struct Sys; @@ -260,7 +263,7 @@ impl Pal for Sys { unsafe fn fork() -> Result { // TODO: Find way to avoid lock. - let _guard = clone::wrlock(); + let _guard = CLONE_LOCK.write(); Ok(clone::fork_impl()? as pid_t) } @@ -726,7 +729,7 @@ impl Pal for Sys { } unsafe fn rlct_clone(stack: *mut usize) -> Result { - let _guard = clone::rdlock(); + let _guard = CLONE_LOCK.read(); let res = clone::rlct_clone_impl(stack); res.map(|mut fd| crate::pthread::OsTid {