Skip to content

Commit

Permalink
Switch from lazy_static to once_cell
Browse files Browse the repository at this point in the history
This also changes the MSRV from 1.34.0 to 1.36.0.
  • Loading branch information
jplatte committed Dec 30, 2020
1 parent 7225dbb commit 0e4aec0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
default: false
image:
type: string
default: 1.34.0
default: 1.36.0
minimal_build:
type: boolean
default: false
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
default: false
image:
type: string
default: 1.34.0
default: 1.36.0
macos:
xcode: "12.2.0"
environment:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup update --no-self-update 1.34.0 && rustup default 1.34.0
run: rustup update --no-self-update 1.36.0 && rustup default 1.36.0
- name: Get rust version
id: rust-version
run: echo "::set-output name=version::$(rustc --version)"
Expand Down
2 changes: 1 addition & 1 deletion openssl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ vendored = ['openssl-sys/vendored']
bitflags = "1.0"
cfg-if = "1.0"
foreign-types = "0.3.1"
lazy_static = "1"
libc = "0.2"
once_cell = "1.5.2"

openssl-sys = { version = "0.9.60", path = "../openssl-sys" }

Expand Down
3 changes: 1 addition & 2 deletions openssl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ extern crate bitflags;
extern crate cfg_if;
#[macro_use]
extern crate foreign_types;
#[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate once_cell;
extern crate openssl_sys as ffi;

#[cfg(test)]
Expand Down
6 changes: 3 additions & 3 deletions openssl/src/ssl/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ cfg_if! {
GeneralName, X509NameRef, X509Ref, X509StoreContext, X509StoreContextRef,
X509VerifyResult,
};
use once_cell::sync::Lazy;

lazy_static! {
pub static ref HOSTNAME_IDX: Index<Ssl, String> = Ssl::new_ex_index().unwrap();
}
pub static HOSTNAME_IDX: Lazy<Index<Ssl, String>> =
Lazy::new(|| Ssl::new_ex_index().unwrap());

pub fn verify_callback(preverify_ok: bool, x509_ctx: &mut X509StoreContextRef) -> bool {
if !preverify_ok || x509_ctx.error_depth() != 0 {
Expand Down
9 changes: 4 additions & 5 deletions openssl/src/ssl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ use ex_data::Index;
use hash::MessageDigest;
#[cfg(ossl110)]
use nid::Nid;
use once_cell::sync::Lazy;
use pkey::{HasPrivate, PKeyRef, Params, Private};
use srtp::{SrtpProtectionProfile, SrtpProtectionProfileRef};
use ssl::bio::BioMethod;
Expand Down Expand Up @@ -512,11 +513,9 @@ impl NameType {
}
}

lazy_static! {
static ref INDEXES: Mutex<HashMap<TypeId, c_int>> = Mutex::new(HashMap::new());
static ref SSL_INDEXES: Mutex<HashMap<TypeId, c_int>> = Mutex::new(HashMap::new());
static ref SESSION_CTX_INDEX: Index<Ssl, SslContext> = Ssl::new_ex_index().unwrap();
}
static INDEXES: Lazy<Mutex<HashMap<TypeId, c_int>>> = Lazy::new(|| Mutex::new(HashMap::new()));
static SSL_INDEXES: Lazy<Mutex<HashMap<TypeId, c_int>>> = Lazy::new(|| Mutex::new(HashMap::new()));
static SESSION_CTX_INDEX: Lazy<Index<Ssl, SslContext>> = Lazy::new(|| Ssl::new_ex_index().unwrap());

unsafe extern "C" fn free_data_box<T>(
_parent: *mut c_void,
Expand Down

0 comments on commit 0e4aec0

Please sign in to comment.