summaryrefslogtreecommitdiff
path: root/src/rust/uci/mod.rs
diff options
context:
space:
mode:
authorChih-Yu Huang <akahuang@google.com>2022-02-04 15:49:42 +0900
committerChih-Yu Huang <akahuang@google.com>2022-02-08 11:58:25 +0900
commite06fd9b74a5b734a7854f4b95a7ae0eaba786874 (patch)
tree9135ebf59f90f647f130817c85cb240689ae95a3 /src/rust/uci/mod.rs
parentccd1a5cf3558684cd0363667286f2703adf430b8 (diff)
downloaduwb-e06fd9b74a5b734a7854f4b95a7ae0eaba786874.tar.gz
uci-rust: handle the panic in the working thread
This CL handles the panic inside the working thread that makes the exit() method returns a Error. Bug: 216552887 Test: atest --host libuwb_uci_rust_tests pass Test: make the thread panic and confirm the test fails Change-Id: I1b3517bc5a40c28aa378a2410ef3811a65c3cfd3
Diffstat (limited to 'src/rust/uci/mod.rs')
-rw-r--r--src/rust/uci/mod.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/rust/uci/mod.rs b/src/rust/uci/mod.rs
index 3fd4376..6c48433 100644
--- a/src/rust/uci/mod.rs
+++ b/src/rust/uci/mod.rs
@@ -508,8 +508,13 @@ impl Dispatcher {
pub fn exit(&mut self) -> Result<()> {
self.send_jni_command(JNICommand::Exit)?;
- let _ = self.runtime.block_on(&mut self.join_handle);
- Ok(())
+ match self.runtime.block_on(&mut self.join_handle) {
+ Err(err) if err.is_panic() => {
+ error!("Driver thread is panic!");
+ Err(UwbErr::Undefined)
+ }
+ _ => Ok(()),
+ }
}
}
@@ -546,8 +551,7 @@ mod tests {
})?;
dispatcher.send_jni_command(JNICommand::Enable)?;
- dispatcher.exit()?;
- Ok(())
+ dispatcher.exit()
}
#[test]
@@ -557,7 +561,6 @@ mod tests {
})?;
dispatcher.send_jni_command(JNICommand::Disable(true))?;
- dispatcher.exit()?;
- Ok(())
+ dispatcher.exit()
}
}