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
1 changed files with 15 additions and 10 deletions

View File

@ -70,16 +70,21 @@ pub fn process_transaction(keyed_accounts: &mut [KeyedAccount], tx_data: &[u8])
trace!("Call native {:?}", name);
let path = create_path(&name);
// 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();
unsafe {
let entrypoint: Symbol<Entrypoint> = match library.get(ENTRYPOINT.as_bytes()) {
Ok(s) => s,
Err(e) => {
warn!("{:?}: Unable to find {:?} in program", e, ENTRYPOINT);
return false;
}
};
return entrypoint(&mut keyed_accounts[1..], tx_data);
match Library::open(Some(&path), libc::RTLD_NODELETE | libc::RTLD_NOW) {
Ok(library) => unsafe {
let entrypoint: Symbol<Entrypoint> = match library.get(ENTRYPOINT.as_bytes()) {
Ok(s) => s,
Err(e) => {
warn!("{:?}: Unable to find {:?} in program", e, ENTRYPOINT);
return false;
}
};
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) {
match instruction {