Commit 01927c19 authored by Steven Fackler's avatar Steven Fackler
Browse files

Initialize OpenSSL in DSA constructor

This fixes the double unlock errors that were popping up on circle
parent a02f039c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ use std::sync::{Once, ONCE_INIT};
use std::mem;
use std::ptr;
use std::process;
use std::io::{self, Write};

use libc::{c_int, c_char, c_void, c_long, c_uchar, size_t, c_uint, c_ulong};
#[cfg(not(ossl101))]
@@ -748,7 +749,11 @@ unsafe extern "C" fn locking_function(mode: c_int, n: c_int, _file: *const c_cha
        (*GUARDS)[n as usize] = Some(mutex.lock().unwrap());
    } else {
        if let None = (*GUARDS)[n as usize].take() {
            println!("lock {} already unlocked", n);
            let _ = writeln!(
                io::stderr(),
                "BUG: rust-openssl lock {} already unlocked, aborting",
                n
            );
            process::abort();
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ impl DsaRef {
impl Dsa {
    /// Generate a DSA key pair.
    pub fn generate(bits: u32) -> Result<Dsa, ErrorStack> {
        ffi::init();
        unsafe {
            let dsa = Dsa(try!(cvt_p(ffi::DSA_new())));
            try!(cvt(ffi::DSA_generate_parameters_ex(