Support the dynlock API
Also actually run tests after compiling them >_>
This commit is contained in:
parent
46cf3f0791
commit
af1a056788
|
|
@ -10,6 +10,6 @@ before_script:
|
||||||
- openssl s_server -accept 15418 -www -cert test/cert.pem -key test/key.pem >/dev/null &
|
- openssl s_server -accept 15418 -www -cert test/cert.pem -key test/key.pem >/dev/null &
|
||||||
- ./configure
|
- ./configure
|
||||||
script:
|
script:
|
||||||
- make all test doc
|
- make all check doc
|
||||||
after_success:
|
after_success:
|
||||||
- curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh
|
- curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh
|
||||||
|
|
|
||||||
12
ssl/ffi.rs
12
ssl/ffi.rs
|
|
@ -102,10 +102,14 @@ pub static XN_FLAG_MULTILINE: c_ulong = 0x2a40006;
|
||||||
#[link(name="crypto")]
|
#[link(name="crypto")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn CRYPTO_num_locks() -> c_int;
|
pub fn CRYPTO_num_locks() -> c_int;
|
||||||
pub fn CRYPTO_set_locking_callback(func: extern "C" fn(mode: c_int,
|
pub fn CRYPTO_set_locking_callback(
|
||||||
n: c_int,
|
func: extern fn(mode: c_int, n: c_int, file: *c_char, line: c_int));
|
||||||
file: *c_char,
|
pub fn CRYPTO_set_dynlock_create_callback(
|
||||||
line: c_int));
|
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;
|
pub fn ERR_get_error() -> c_ulong;
|
||||||
|
|
||||||
|
|
|
||||||
28
ssl/mod.rs
28
ssl/mod.rs
|
|
@ -41,6 +41,9 @@ fn init() {
|
||||||
MUTEXES = cast::transmute(mutexes);
|
MUTEXES = cast::transmute(mutexes);
|
||||||
|
|
||||||
ffi::CRYPTO_set_locking_callback(locking_function);
|
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
|
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) {
|
_line: c_int) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mutex = (*MUTEXES).get_mut(n as uint);
|
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 {
|
-> c_int {
|
||||||
unsafe {
|
unsafe {
|
||||||
let idx = ffi::SSL_get_ex_data_X509_STORE_CTX_idx();
|
let idx = ffi::SSL_get_ex_data_X509_STORE_CTX_idx();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue