diff options
| author | Steven Fackler <[email protected]> | 2014-03-18 19:13:38 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2014-03-18 19:13:38 -0700 |
| commit | af1a05678825e30a802ea09383658248d09d2dee (patch) | |
| tree | 3664c6609c98aa06bc28bdc3d8e879db8a5997d9 /ssl/mod.rs | |
| parent | SSL session closure should be treated like EOF (diff) | |
| download | rust-openssl-af1a05678825e30a802ea09383658248d09d2dee.tar.xz rust-openssl-af1a05678825e30a802ea09383658248d09d2dee.zip | |
Support the dynlock API
Also actually run tests after compiling them >_>
Diffstat (limited to 'ssl/mod.rs')
| -rw-r--r-- | ssl/mod.rs | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -41,6 +41,9 @@ 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); }); } } @@ -87,7 +90,7 @@ pub enum SslVerifyMode { SslVerifyNone = ffi::SSL_VERIFY_NONE } -extern "C" 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) { unsafe { let mutex = (*MUTEXES).get_mut(n as uint); @@ -100,7 +103,28 @@ extern "C" fn locking_function(mode: c_int, n: c_int, _file: *c_char, } } -extern "C" fn raw_verify(preverify_ok: c_int, x509_ctx: *ffi::X509_STORE_CTX) +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 { + 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) { + unsafe { let _mutex: ~NativeMutex = cast::transmute(l); } +} + +extern fn raw_verify(preverify_ok: c_int, x509_ctx: *ffi::X509_STORE_CTX) -> c_int { unsafe { let idx = ffi::SSL_get_ex_data_X509_STORE_CTX_idx(); |