Avoid panicking when a native library doesn't exist

This commit is contained in:
Michael Vines
2018-10-30 11:41:23 -07:00
committed by Grimes
parent 009c71f7e2
commit 3a73a09391

View File

@ -70,8 +70,8 @@ pub fn process_transaction(keyed_accounts: &mut [KeyedAccount], tx_data: &[u8])
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 // TODO linux tls bug can cause crash on dlclose(), workaround by never unloading
let library = Library::open(Some(path), libc::RTLD_NODELETE | libc::RTLD_NOW).unwrap(); match Library::open(Some(&path), libc::RTLD_NODELETE | libc::RTLD_NOW) {
unsafe { Ok(library) => unsafe {
let entrypoint: Symbol<Entrypoint> = match library.get(ENTRYPOINT.as_bytes()) { let entrypoint: Symbol<Entrypoint> = match library.get(ENTRYPOINT.as_bytes()) {
Ok(s) => s, Ok(s) => s,
Err(e) => { Err(e) => {
@ -80,6 +80,11 @@ pub fn process_transaction(keyed_accounts: &mut [KeyedAccount], tx_data: &[u8])
} }
}; };
return entrypoint(&mut keyed_accounts[1..], tx_data); return entrypoint(&mut keyed_accounts[1..], tx_data);
},
Err(e) => {
warn!("Unable to load: {:?}", e);
return false;
}
} }
} else if let Ok(instruction) = deserialize(tx_data) { } else if let Ok(instruction) = deserialize(tx_data) {
match instruction { match instruction {