summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2022-12-19 23:16:30 +0000
committer David Brazdil <dbrazdil@google.com> 2022-12-19 23:49:16 +0000
commit793e8792a20b61c470b4f578a30ccfedfef482a9 (patch)
tree9b1f804fef48748c0aac8e98d0178e14fb3e3641
parente1bd9839fe48974877dd710f78798035fce3e711 (diff)
rpc_binder: Mark ARpcServer_shutdown [[nodiscard]]
The function can fail. Propagate the return value from C++ to both C and Rust wrappers. Bug: 245727626 Test: builds Change-Id: Idf6e6d9002119173d76fe25f73856a0768bb46a1
-rw-r--r--libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp2
-rw-r--r--libs/binder/libbinder_rpc_unstable.cpp4
-rw-r--r--libs/binder/rust/rpcbinder/src/server.rs8
3 files changed, 9 insertions, 5 deletions
diff --git a/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp b/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp
index 311db2e3be..3ebbed6965 100644
--- a/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp
+++ b/libs/binder/include_rpc_unstable/binder_rpc_unstable.hpp
@@ -73,7 +73,7 @@ void ARpcServer_start(ARpcServer* server);
void ARpcServer_join(ARpcServer* server);
// Shuts down any running ARpcServer_join().
-void ARpcServer_shutdown(ARpcServer* server);
+[[nodiscard]] bool ARpcServer_shutdown(ARpcServer* server);
// Frees the ARpcServer handle and drops the reference count on the underlying
// RpcServer instance. The handle must not be reused afterwards.
diff --git a/libs/binder/libbinder_rpc_unstable.cpp b/libs/binder/libbinder_rpc_unstable.cpp
index 8886f7d856..89ef46d5c3 100644
--- a/libs/binder/libbinder_rpc_unstable.cpp
+++ b/libs/binder/libbinder_rpc_unstable.cpp
@@ -157,8 +157,8 @@ void ARpcServer_join(ARpcServer* handle) {
handleToStrongPointer<RpcServer>(handle)->join();
}
-void ARpcServer_shutdown(ARpcServer* handle) {
- handleToStrongPointer<RpcServer>(handle)->shutdown();
+bool ARpcServer_shutdown(ARpcServer* handle) {
+ return handleToStrongPointer<RpcServer>(handle)->shutdown();
}
void ARpcServer_free(ARpcServer* handle) {
diff --git a/libs/binder/rust/rpcbinder/src/server.rs b/libs/binder/rust/rpcbinder/src/server.rs
index 73a2aa2f27..761b306a1e 100644
--- a/libs/binder/rust/rpcbinder/src/server.rs
+++ b/libs/binder/rust/rpcbinder/src/server.rs
@@ -140,7 +140,11 @@ impl RpcServerRef {
/// Shuts down the running RpcServer. Can be called multiple times and from
/// multiple threads. Called automatically during drop().
- pub fn shutdown(&self) {
- unsafe { binder_rpc_unstable_bindgen::ARpcServer_shutdown(self.as_ptr()) };
+ pub fn shutdown(&self) -> Result<(), Error> {
+ if unsafe { binder_rpc_unstable_bindgen::ARpcServer_shutdown(self.as_ptr()) } {
+ Ok(())
+ } else {
+ Err(Error::from(ErrorKind::UnexpectedEof))
+ }
}
}