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

Commit a04030b5 authored by Andrei Homescu's avatar Andrei Homescu
Browse files

RPC Binder: Shut down the session on disconnect

For parity with the Android code, RpcServerTrusty now
calls shutdownAndWait whenever a channel disconnects.
This should also mitigate some server-side leaks, since
the session shutdown code also clears RpcState.

Bug: 267235876
Test: trusty_stats_test 80 times consecutively
Change-Id: I35c3cd9fd419aa51e70297d1ffe3aa5dab7a0816
parent b1e815fe
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -154,8 +154,18 @@ int RpcServerTrusty::handleMessage(const tipc_port* /*port*/, handle_t /*chan*/,
    return NO_ERROR;
}

void RpcServerTrusty::handleDisconnect(const tipc_port* /*port*/, handle_t /*chan*/,
                                       void* /*ctx*/) {}
void RpcServerTrusty::handleDisconnect(const tipc_port* /*port*/, handle_t /*chan*/, void* ctx) {
    auto* channelContext = reinterpret_cast<ChannelContext*>(ctx);
    if (channelContext == nullptr) {
        // Connections marked "incoming" (outgoing from the server's side)
        // do not have a valid channel context because joinFn does not get
        // called for them. We ignore them here.
        return;
    }

    auto& session = channelContext->session;
    (void)session->shutdownAndWait(false);
}

void RpcServerTrusty::handleChannelCleanup(void* ctx) {
    auto* channelContext = reinterpret_cast<ChannelContext*>(ctx);