Use Library::new() for windows (#4544)

This commit is contained in:
Michael Vines
2019-06-04 21:49:05 -07:00
committed by GitHub
parent aa88c40a9e
commit 82bd2df986

View File

@ -55,6 +55,17 @@ fn create_path(name: &str) -> PathBuf {
} }
} }
#[cfg(windows)]
fn library_open(path: &PathBuf) -> std::io::Result<Library> {
Library::new(path)
}
#[cfg(not(windows))]
fn library_open(path: &PathBuf) -> std::io::Result<Library> {
// TODO linux tls bug can cause crash on dlclose(), workaround by never unloading
Library::open(Some(path), libc::RTLD_NODELETE | libc::RTLD_NOW)
}
pub fn entrypoint( pub fn entrypoint(
program_id: &Pubkey, program_id: &Pubkey,
keyed_accounts: &mut [KeyedAccount], keyed_accounts: &mut [KeyedAccount],
@ -79,8 +90,7 @@ pub fn entrypoint(
}; };
trace!("Call native {:?}", name); trace!("Call native {:?}", name);
let path = create_path(&name); let path = create_path(&name);
// TODO linux tls bug can cause crash on dlclose(), workaround by never unloading match library_open(&path) {
match Library::open(Some(&path), libc::RTLD_NODELETE | libc::RTLD_NOW) {
Ok(library) => unsafe { Ok(library) => unsafe {
let entrypoint: Symbol<instruction_processor_utils::Entrypoint> = let entrypoint: Symbol<instruction_processor_utils::Entrypoint> =
match library.get(instruction_processor_utils::ENTRYPOINT.as_bytes()) { match library.get(instruction_processor_utils::ENTRYPOINT.as_bytes()) {