Commit 0c1e4194 authored by Steven Fackler's avatar Steven Fackler
Browse files

Revert "Support the dynlock API"

This reverts commit af1a0567.

This seems to cause Travis to segfault every once in a while. I've never
been able to reproduce the instability locally, so I'm just going to
pull this.
parent 1fd8efd0
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -101,14 +101,10 @@ pub static XN_FLAG_MULTILINE: c_ulong = 0x2a40006;
#[link(name="crypto")]
extern "C" {
    pub fn CRYPTO_num_locks() -> c_int;
    pub fn CRYPTO_set_locking_callback(
        func: extern fn(mode: c_int, n: c_int, file: *c_char, line: c_int));
    pub fn CRYPTO_set_dynlock_create_callback(
        func: extern fn(file: *c_char, line: c_int) -> *c_void);
    pub fn CRYPTO_set_dynlock_lock_callback(
        func: extern fn(mode: c_int, l: *c_void, file: *c_char, line: c_int));
    pub fn CRYPTO_set_dynlock_destroy_callback(
        func: extern fn(l: *c_void, file: *c_char, line: c_int));
    pub fn CRYPTO_set_locking_callback(func: extern "C" fn(mode: c_int,
                                                           n: c_int,
                                                           file: *c_char,
                                                           line: c_int));

    pub fn ERR_get_error() -> c_ulong;

+8 −24
Original line number Diff line number Diff line
@@ -40,9 +40,6 @@ fn init() {
            MUTEXES = cast::transmute(mutexes);

            ffi::CRYPTO_set_locking_callback(locking_function);
            ffi::CRYPTO_set_dynlock_create_callback(dyn_create_function);
            ffi::CRYPTO_set_dynlock_lock_callback(dyn_lock_function);
            ffi::CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function);
        });
    }
}
@@ -91,27 +88,14 @@ pub enum SslVerifyMode {

extern fn locking_function(mode: c_int, n: c_int, _file: *c_char,
                               _line: c_int) {
    unsafe { inner_lock(mode, (*MUTEXES).get_mut(n as uint)); }
}

extern fn dyn_create_function(_file: *c_char, _line: c_int) -> *c_void {
    unsafe { cast::transmute(~NativeMutex::new()) }
}

extern fn dyn_lock_function(mode: c_int, l: *c_void, _file: *c_char,
                            _line: c_int) {
    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 {
        let mutex = (*MUTEXES).get_mut(n as uint);

unsafe fn inner_lock(mode: c_int, lock: &mut NativeMutex) {
        if mode & ffi::CRYPTO_LOCK != 0 {
        lock.lock_noguard();
            mutex.lock_noguard();
        } else {
        lock.unlock_noguard();
            mutex.unlock_noguard();
        }
    }
}