Merge "authgraph: cope with LocalTa being dropped" into main am: 05758a581f am: 56d9e0c889 am: 4277602a47

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2880768

Change-Id: I63e2a76add92da896f6c8c8c49328c59986660d0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
David Drysdale 2023-12-19 10:56:32 +00:00 committed by Automerger Merge Worker
commit 520df5c804

View file

@ -22,6 +22,7 @@ use authgraph_core::{
ta::{AuthGraphTa, Role},
};
use authgraph_hal::channel::SerializedChannel;
use log::error;
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::{mpsc, Mutex};
@ -57,10 +58,23 @@ impl LocalTa {
);
// Loop forever processing request messages.
loop {
let req_data: Vec<u8> = in_rx.recv().expect("failed to receive next req");
let req_data: Vec<u8> = match in_rx.recv() {
Ok(data) => data,
Err(_) => {
error!("local TA failed to receive request!");
break;
}
};
let rsp_data = ta.process(&req_data);
out_tx.send(rsp_data).expect("failed to send out rsp");
match out_tx.send(rsp_data) {
Ok(_) => {}
Err(_) => {
error!("local TA failed to send out response");
break;
}
}
}
error!("local TA terminating!");
});
Ok(Self {
channels: Mutex::new(Channels { in_tx, out_rx }),