Skip to content

Commit 44a0819

Browse files
committed
workaround openssl shutdown race condition
refs: openssl/openssl#6214 refs: sfackler/rust-openssl#1324
1 parent 2f6032b commit 44a0819

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

libssh-rs/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libssh-rs"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
edition = "2018"
55
repository = "https://github.com/wez/libssh-rs"
66
description = "Bindings to the libssh library"
@@ -12,6 +12,10 @@ license = "MIT"
1212
bitflags = "1.3"
1313
libssh-rs-sys = { version = "0.1.3", path = "../libssh-rs-sys" }
1414
thiserror = "1.0"
15+
# Pinned on this last version with openssl-src-300 until a newer release
16+
# is made that unblocks it.
17+
# <https://github.com/sfackler/rust-openssl/pull/1578>
18+
openssl-sys = "=0.9.71"
1519

1620
[features]
1721
vendored = ["libssh-rs-sys/vendored"]

libssh-rs/src/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ pub use crate::sftp::*;
3131
struct LibraryState {}
3232
impl LibraryState {
3333
pub fn new() -> Option<Self> {
34+
// Force openssl to initialize.
35+
// In theory, we don't need this, but in practice we do because of
36+
// this bug:
37+
// <https://github.com/openssl/openssl/issues/6214>
38+
// which weirdly requires that *all* openssl threads be joined before
39+
// the process exits, which is an unrealistic expectation on behalf
40+
// of that library.
41+
// That was worked around in openssl_sys:
42+
// <https://github.com/sfackler/rust-openssl/pull/1324>
43+
// which tells openssl to skip the process-wide shutdown.
44+
openssl_sys::init();
3445
let res = unsafe { sys::ssh_init() };
3546
if res != sys::SSH_OK as i32 {
3647
None

0 commit comments

Comments
 (0)