proxmox-shared-memory: depend on libc 0.2.107

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2021-11-15 11:29:53 +01:00
parent e3a14098f7
commit ece92bde29
2 changed files with 4 additions and 29 deletions

View File

@ -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 }

View File

@ -1,8 +1,6 @@
use std::cell::UnsafeCell;
use std::mem::MaybeUninit;
//use anyhow::Error;
#[derive(Debug)]
pub(crate) struct RawSharedMutex {
inner: UnsafeCell<libc::pthread_mutex_t>,
@ -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;
}