aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2014-03-18 19:13:38 -0700
committerSteven Fackler <[email protected]>2014-03-18 19:13:38 -0700
commitaf1a05678825e30a802ea09383658248d09d2dee (patch)
tree3664c6609c98aa06bc28bdc3d8e879db8a5997d9
parentSSL session closure should be treated like EOF (diff)
downloadrust-openssl-af1a05678825e30a802ea09383658248d09d2dee.tar.xz
rust-openssl-af1a05678825e30a802ea09383658248d09d2dee.zip
Support the dynlock API
Also actually run tests after compiling them >_>
-rw-r--r--.travis.yml2
-rw-r--r--ssl/ffi.rs12
-rw-r--r--ssl/mod.rs28
3 files changed, 35 insertions, 7 deletions
diff --git a/.travis.yml b/.travis.yml
index 704a8f76..50ead302 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,6 +10,6 @@ before_script:
- openssl s_server -accept 15418 -www -cert test/cert.pem -key test/key.pem >/dev/null &
- ./configure
script:
- - make all test doc
+ - make all check doc
after_success:
- curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh
diff --git a/ssl/ffi.rs b/ssl/ffi.rs
index 53a3b4f8..021de3fa 100644
--- a/ssl/ffi.rs
+++ b/ssl/ffi.rs
@@ -102,10 +102,14 @@ 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 "C" fn(mode: c_int,
- n: c_int,
- file: *c_char,
- line: 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 ERR_get_error() -> c_ulong;
diff --git a/ssl/mod.rs b/ssl/mod.rs
index bd7ff445..206eabf4 100644
--- a/ssl/mod.rs
+++ b/ssl/mod.rs
@@ -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();