Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 793e8792 authored by David Brazdil's avatar David Brazdil
Browse files

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
parent e1bd9839
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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.
+2 −2
Original line number Diff line number Diff line
@@ -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) {
+6 −2
Original line number Diff line number Diff line
@@ -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))
        }
    }
}