about summary refs log tree commit diff
path: root/library/std/src/sys/unix/os.rs
diff options
context:
space:
mode:
authorjoboet <jonasboettiger@icloud.com>2022-08-15 14:33:12 +0200
committerjoboet <jonasboettiger@icloud.com>2022-09-19 23:27:26 +0200
commitbe09a4a8b2eadddadc0f3c00e40917e254ba91ab (patch)
treedeccfa130892af2d5c1032767b0d40035c010b52 /library/std/src/sys/unix/os.rs
parent75b7e52e92c3b00fc891b47f5b2efdff0a2be55a (diff)
downloadrust-be09a4a8b2eadddadc0f3c00e40917e254ba91ab.tar.gz
rust-be09a4a8b2eadddadc0f3c00e40917e254ba91ab.zip
std: use `sync::RwLock` for internal statics
Diffstat (limited to 'library/std/src/sys/unix/os.rs')
-rw-r--r--library/std/src/sys/unix/os.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/library/std/src/sys/unix/os.rs b/library/std/src/sys/unix/os.rs
index 46545a0839f..3c3770708b1 100644
--- a/library/std/src/sys/unix/os.rs
+++ b/library/std/src/sys/unix/os.rs
@@ -17,10 +17,10 @@ use crate::path::{self, PathBuf};
 use crate::ptr;
 use crate::slice;
 use crate::str;
+use crate::sync::{PoisonError, RwLock};
 use crate::sys::cvt;
 use crate::sys::fd;
 use crate::sys::memchr;
-use crate::sys_common::rwlock::{StaticRwLock, StaticRwLockReadGuard};
 use crate::vec;
 
 #[cfg(all(target_env = "gnu", not(target_os = "vxworks")))]
@@ -501,10 +501,10 @@ pub unsafe fn environ() -> *mut *const *const c_char {
     ptr::addr_of_mut!(environ)
 }
 
-static ENV_LOCK: StaticRwLock = StaticRwLock::new();
+static ENV_LOCK: RwLock<()> = RwLock::new(());
 
-pub fn env_read_lock() -> StaticRwLockReadGuard {
-    ENV_LOCK.read()
+pub fn env_read_lock() -> impl Drop {
+    ENV_LOCK.read().unwrap_or_else(PoisonError::into_inner)
 }
 
 /// Returns a vector of (variable, value) byte-vector pairs for all the