Commit 53acce7a authored by Steven Fackler's avatar Steven Fackler
Browse files

Clean up locking code a bit

parent af1a0567
Loading
Loading
Loading
Loading
+10 −18
Original line number Diff line number Diff line
@@ -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 {