fix(pal/redox): use RwLock instead of InnerRwLock

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2024-12-31 01:07:36 +11:00
parent 4232858b89
commit bc51d8e1d5
2 changed files with 5 additions and 24 deletions
-22
View File
@@ -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::*;
+5 -2
View File
@@ -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<pid_t> {
// 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<crate::pthread::OsTid> {
let _guard = clone::rdlock();
let _guard = CLONE_LOCK.read();
let res = clone::rlct_clone_impl(stack);
res.map(|mut fd| crate::pthread::OsTid {