From 0c1e4194f51ad3ff20e1a52f8defbaec26efb64a Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 23 Apr 2014 23:01:29 -0700 Subject: [PATCH] Revert "Support the dynlock API" This reverts commit af1a05678825e30a802ea09383658248d09d2dee. 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. --- ssl/ffi.rs | 12 ++++-------- ssl/mod.rs | 32 ++++++++------------------------ 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/ssl/ffi.rs b/ssl/ffi.rs index 819fb63d..fd6514ae 100644 --- a/ssl/ffi.rs +++ b/ssl/ffi.rs @@ -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; diff --git a/ssl/mod.rs b/ssl/mod.rs index b43289eb..4564bce9 100644 --- a/ssl/mod.rs +++ b/ssl/mod.rs @@ -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); }); } } @@ -90,28 +87,15 @@ 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)); } -} + _line: c_int) { + unsafe { + let mutex = (*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 fn inner_lock(mode: c_int, lock: &mut NativeMutex) { - if mode & ffi::CRYPTO_LOCK != 0 { - lock.lock_noguard(); - } else { - lock.unlock_noguard(); + if mode & ffi::CRYPTO_LOCK != 0 { + mutex.lock_noguard(); + } else { + mutex.unlock_noguard(); + } } }