Clean up locking code a bit
This commit is contained in:
parent
af1a056788
commit
53acce7a98
28
ssl/mod.rs
28
ssl/mod.rs
|
|
@ -92,15 +92,7 @@ pub enum SslVerifyMode {
|
||||||
|
|
||||||
extern fn locking_function(mode: c_int, n: c_int, _file: *c_char,
|
extern fn locking_function(mode: c_int, n: c_int, _file: *c_char,
|
||||||
_line: c_int) {
|
_line: c_int) {
|
||||||
unsafe {
|
unsafe { inner_lock(mode, (*MUTEXES).get_mut(n as uint)); }
|
||||||
let mutex = (*MUTEXES).get_mut(n as uint);
|
|
||||||
|
|
||||||
if mode & ffi::CRYPTO_LOCK != 0 {
|
|
||||||
mutex.lock_noguard();
|
|
||||||
} else {
|
|
||||||
mutex.unlock_noguard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn dyn_create_function(_file: *c_char, _line: c_int) -> *c_void {
|
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,
|
extern fn dyn_lock_function(mode: c_int, l: *c_void, _file: *c_char,
|
||||||
_line: c_int) {
|
_line: c_int) {
|
||||||
unsafe {
|
unsafe { inner_lock(mode, cast::transmute(l)); }
|
||||||
let mutex: &mut NativeMutex = cast::transmute(l);
|
|
||||||
|
|
||||||
if mode & ffi::CRYPTO_LOCK != 0 {
|
|
||||||
mutex.lock_noguard();
|
|
||||||
} else {
|
|
||||||
mutex.unlock_noguard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn dyn_destroy_function(l: *c_void, _file: *c_char, _line: c_int) {
|
extern fn dyn_destroy_function(l: *c_void, _file: *c_char, _line: c_int) {
|
||||||
unsafe { let _mutex: ~NativeMutex = cast::transmute(l); }
|
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)
|
extern fn raw_verify(preverify_ok: c_int, x509_ctx: *ffi::X509_STORE_CTX)
|
||||||
-> c_int {
|
-> c_int {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue