summaryrefslogtreecommitdiff
path: root/libssh2-sys/lib.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-05-08 09:10:11 -0700
committerAlex Crichton <alex@alexcrichton.com>2017-05-08 09:12:47 -0700
commit0a2c2694eaaed9196f3ee869dd9ea2f3c1fa5019 (patch)
treef0ebfb29ca272789631fbe80719a3197796cee79 /libssh2-sys/lib.rs
parent91c0d623cf787b18dc4245476877d8aeced01160 (diff)
downloadssh2-rs-0a2c2694eaaed9196f3ee869dd9ea2f3c1fa5019.zip
Initialize all crypto on Windows
If we don't then apparently nothing works, spooky! Closes alexcrichton/git2-rs#202
Diffstat (limited to 'libssh2-sys/lib.rs')
-rw-r--r--libssh2-sys/lib.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/libssh2-sys/lib.rs b/libssh2-sys/lib.rs
index 2432b55..381d810 100644
--- a/libssh2-sys/lib.rs
+++ b/libssh2-sys/lib.rs
@@ -542,16 +542,24 @@ pub fn init() {
static INIT: Once = ONCE_INIT;
INIT.call_once(|| unsafe {
platform_init();
- assert_eq!(libssh2_init(LIBSSH2_INIT_NO_CRYPTO), 0);
assert_eq!(libc::atexit(shutdown), 0);
});
extern fn shutdown() { unsafe { libssh2_exit(); } }
#[cfg(unix)]
- fn platform_init() {
+ unsafe fn platform_init() {
+ // On Unix we want to funnel through openssl_sys to initialize OpenSSL,
+ // so be sure to tell libssh2 to not do its own thing as we've already
+ // taken care of it.
openssl_sys::init();
+ assert_eq!(libssh2_init(LIBSSH2_INIT_NO_CRYPTO), 0);
}
#[cfg(windows)]
- fn platform_init() {}
+ unsafe fn platform_init() {
+ // On Windows we want to be sure to tell libssh2 to initialize
+ // everything, as we're not managing crypto elsewhere ourselves. Also to
+ // fix alexcrichton/git2-rs#202
+ assert_eq!(libssh2_init(0), 0);
+ }
}