rpc_binder: Refactor users of RpcServer to use new API
The Rust wrapper around RpcServer now returns a handle instead of
waiting for the server to finish. This allows us to simplify the users
of that API.
Test: atest -p packages/modules/Virtualization:avf-presubmit
Change-Id: I4b41f9f911f7d78e8149f6e3268aa2177596e2e5
diff --git a/compos/src/compsvc_main.rs b/compos/src/compsvc_main.rs
index a4e3903..206dd4b 100644
--- a/compos/src/compsvc_main.rs
+++ b/compos/src/compsvc_main.rs
@@ -22,10 +22,10 @@
mod compsvc;
mod fsverity;
-use anyhow::{bail, Result};
+use anyhow::Result;
use compos_common::COMPOS_VSOCK_PORT;
use log::{debug, error};
-use rpcbinder::run_vsock_rpc_server;
+use rpcbinder::RpcServer;
use std::panic;
use vm_payload_bindgen::AVmPayload_notifyPayloadReady;
@@ -45,16 +45,11 @@
error!("{}", panic_info);
}));
- let service = compsvc::new_binder()?.as_binder();
debug!("compsvc is starting as a rpc service.");
+ let service = compsvc::new_binder()?.as_binder();
+ let server = RpcServer::new_vsock(service, COMPOS_VSOCK_PORT)?;
// SAFETY: Invokes a method from the bindgen library `vm_payload_bindgen`.
- let retval = run_vsock_rpc_server(service, COMPOS_VSOCK_PORT, || unsafe {
- AVmPayload_notifyPayloadReady();
- });
- if retval {
- debug!("RPC server has shut down gracefully");
- Ok(())
- } else {
- bail!("Premature termination of RPC server");
- }
+ unsafe { AVmPayload_notifyPayloadReady() };
+ server.join();
+ Ok(())
}