aboutsummaryrefslogtreecommitdiff
path: root/src/ssl
diff options
context:
space:
mode:
authorValerii Hiora <[email protected]>2014-10-13 17:41:03 +0300
committerValerii Hiora <[email protected]>2014-10-14 08:31:42 +0300
commitdd46d1922e4706cf4c15c8cd915c1254363def8c (patch)
tree9be063d21a6ca4c90f20be1dd54d0dc3144b959f /src/ssl
parentMerge pull request #83 from jmesmon/set-cipher-list (diff)
downloadrust-openssl-dd46d1922e4706cf4c15c8cd915c1254363def8c.tar.xz
rust-openssl-dd46d1922e4706cf4c15c8cd915c1254363def8c.zip
Correct init mutexes and locking function
`libcrypto` uses locks quite intensively even without SSL. So they should be initialized before everything else to function properly in multi-threaded apps in which SSL operations are absent or delayed. Finishes #79
Diffstat (limited to 'src/ssl')
-rw-r--r--src/ssl/mod.rs23
1 files changed, 1 insertions, 22 deletions
diff --git a/src/ssl/mod.rs b/src/ssl/mod.rs
index 86b3ec83..0ed3c2e8 100644
--- a/src/ssl/mod.rs
+++ b/src/ssl/mod.rs
@@ -1,8 +1,7 @@
-use libc::{c_int, c_void, c_char, c_long};
+use libc::{c_int, c_void, c_long};
use std::io::{IoResult, IoError, EndOfFile, Stream, Reader, Writer};
use std::mem;
use std::ptr;
-use std::rt::mutex::NativeMutex;
use std::string;
use sync::one::{Once, ONCE_INIT};
@@ -16,7 +15,6 @@ pub mod error;
mod tests;
static mut VERIFY_IDX: c_int = -1;
-static mut MUTEXES: *mut Vec<NativeMutex> = 0 as *mut Vec<NativeMutex>;
fn init() {
static mut INIT: Once = ONCE_INIT;
@@ -29,12 +27,6 @@ fn init() {
None, None);
assert!(verify_idx >= 0);
VERIFY_IDX = verify_idx;
-
- let num_locks = ffi::CRYPTO_num_locks();
- let mutexes = box Vec::from_fn(num_locks as uint, |_| NativeMutex::new());
- MUTEXES = mem::transmute(mutexes);
-
- ffi::CRYPTO_set_locking_callback(locking_function);
});
}
}
@@ -109,19 +101,6 @@ fn get_verify_data_idx<T>() -> c_int {
}
}
-extern fn locking_function(mode: c_int, n: c_int, _file: *const 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();
- }
- }
-}
-
extern fn raw_verify(preverify_ok: c_int, x509_ctx: *mut ffi::X509_STORE_CTX)
-> c_int {
unsafe {