From ece92bde29068bc2756e42bbd49f6b99fd86bf5c Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 15 Nov 2021 11:29:53 +0100 Subject: [PATCH] proxmox-shared-memory: depend on libc 0.2.107 Signed-off-by: Dietmar Maurer --- proxmox-shared-memory/Cargo.toml | 2 +- proxmox-shared-memory/src/raw_shared_mutex.rs | 31 ++----------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/proxmox-shared-memory/Cargo.toml b/proxmox-shared-memory/Cargo.toml index 7b827d68..d109dabd 100644 --- a/proxmox-shared-memory/Cargo.toml +++ b/proxmox-shared-memory/Cargo.toml @@ -10,7 +10,7 @@ exclude = [ "debian" ] [dependencies] anyhow = "1.0" -libc = "0.2" +libc = "0.2.107" nix = "0.19.1" proxmox = { path = "../proxmox", version = "0.15", default-features = false } diff --git a/proxmox-shared-memory/src/raw_shared_mutex.rs b/proxmox-shared-memory/src/raw_shared_mutex.rs index 34768756..793e7fd6 100644 --- a/proxmox-shared-memory/src/raw_shared_mutex.rs +++ b/proxmox-shared-memory/src/raw_shared_mutex.rs @@ -1,8 +1,6 @@ use std::cell::UnsafeCell; use std::mem::MaybeUninit; -//use anyhow::Error; - #[derive(Debug)] pub(crate) struct RawSharedMutex { inner: UnsafeCell, @@ -26,7 +24,7 @@ impl RawSharedMutex { .unwrap(); cvt_nz(libc::pthread_mutexattr_setpshared(attr.0.as_mut_ptr(), libc::PTHREAD_PROCESS_SHARED)) .unwrap(); - cvt_nz(pthread_mutexattr_setrobust(attr.0.as_mut_ptr(), PTHREAD_MUTEX_ROBUST)) + cvt_nz(libc::pthread_mutexattr_setrobust(attr.0.as_mut_ptr(), libc::PTHREAD_MUTEX_ROBUST)) .unwrap(); cvt_nz(libc::pthread_mutex_init(self.inner.get(), attr.0.as_ptr())).unwrap(); } @@ -35,7 +33,7 @@ impl RawSharedMutex { pub unsafe fn lock(&self) { let mut r = libc::pthread_mutex_lock(self.inner.get()); if r == libc::EOWNERDEAD { - r = pthread_mutex_consistent(self.inner.get()); + r = libc::pthread_mutex_consistent(self.inner.get()); } debug_assert_eq!(r, 0); @@ -51,19 +49,11 @@ impl RawSharedMutex { pub unsafe fn try_lock(&self) -> bool { let mut r = libc::pthread_mutex_trylock(self.inner.get()); if r == libc::EOWNERDEAD { - r = pthread_mutex_consistent(self.inner.get()); + r = libc::pthread_mutex_consistent(self.inner.get()); } r == 0 } - - /* - #[inline] - pub unsafe fn destroy(&self) { - let r = libc::pthread_mutex_destroy(self.inner.get()); - debug_assert_eq!(r, 0); - } - */ } @@ -87,18 +77,3 @@ impl Drop for PthreadMutexAttr<'_> { } } } - -// Those thing need rust libc wrapper 0.2.105 (we have 0.2.94), so -// we import ourselves - -pub const PTHREAD_MUTEX_ROBUST: libc::c_int = 1; - -#[link(name = "c")] -extern { - fn pthread_mutexattr_setrobust( - attr: *mut libc::pthread_mutexattr_t, - robustness: libc::c_int, - ) -> libc::c_int; - - fn pthread_mutex_consistent(mutex: *mut libc::pthread_mutex_t) -> libc::c_int; -}