Clean up locking code a bit

This commit is contained in:
Steven Fackler 2014-03-18 19:20:15 -07:00
parent af1a056788
commit 53acce7a98
1 changed files with 10 additions and 18 deletions

View File

@ -92,15 +92,7 @@ pub enum SslVerifyMode {
extern fn locking_function(mode: c_int, n: c_int, _file: *c_char,
_line: c_int) {
unsafe {
let mutex = (*MUTEXES).get_mut(n as uint);
if mode & ffi::CRYPTO_LOCK != 0 {
mutex.lock_noguard();
} else {
mutex.unlock_noguard();
}
}
unsafe { inner_lock(mode, (*MUTEXES).get_mut(n as uint)); }
}
extern fn dyn_create_function(_file: *c_char, _line: c_int) -> *c_void {
@ -109,21 +101,21 @@ extern fn dyn_create_function(_file: *c_char, _line: c_int) -> *c_void {
extern fn dyn_lock_function(mode: c_int, l: *c_void, _file: *c_char,
_line: c_int) {
unsafe {
let mutex: &mut NativeMutex = cast::transmute(l);
if mode & ffi::CRYPTO_LOCK != 0 {
mutex.lock_noguard();
} else {
mutex.unlock_noguard();
}
}
unsafe { inner_lock(mode, cast::transmute(l)); }
}
extern fn dyn_destroy_function(l: *c_void, _file: *c_char, _line: c_int) {
unsafe { let _mutex: ~NativeMutex = cast::transmute(l); }
}
unsafe fn inner_lock(mode: c_int, lock: &mut NativeMutex) {
if mode & ffi::CRYPTO_LOCK != 0 {
lock.lock_noguard();
} else {
lock.unlock_noguard();
}
}
extern fn raw_verify(preverify_ok: c_int, x509_ctx: *ffi::X509_STORE_CTX)
-> c_int {
unsafe {