Commit 7152ddfa authored by sevenuz's avatar sevenuz
Browse files

client: multi-engine fork re-init and shutdown

at_child() leaks every engine of the pool (not only one) before the
child rebuilds its own engines, so the parent's connections are never
finalized from the child. Shutdown already releases the endpoints of all
engines before the engines themselves (clear_hosts, then IPC, then RPC);
it now logs how many engines it finalizes.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 072d8f28
Loading
Loading
Loading
Loading
+13 −5
Changes for src/client/preload.cpp: 13 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -592,7 +592,10 @@ destroy_preload() {
        LOG(DEBUG, "Shutting down IPC subsystem");
        CTX->ipc_engine(nullptr);
    }
    LOG(DEBUG, "Shutting down RPC subsystem");
    // endpoints of all engines are already released (clear_hosts above);
    // all RPC engines are finalized here
    LOG(DEBUG, "Shutting down RPC subsystem ({} engine(s))",
        CTX->rpc_engine_count());
    CTX->rpc_engine(nullptr);
    LOG(DEBUG, "RPC subsystem shut down");

@@ -647,7 +650,10 @@ gkfs_end() {
        CTX->ipc_engine(nullptr);
    }

    LOG(DEBUG, "Shutting down RPC subsystem");
    // endpoints of all engines are already released (clear_hosts above);
    // all RPC engines are finalized here
    LOG(DEBUG, "Shutting down RPC subsystem ({} engine(s))",
        CTX->rpc_engine_count());
    CTX->rpc_engine(nullptr);
    LOG(DEBUG, "RPC subsystem shut down");

@@ -677,13 +683,15 @@ at_child() {
        LOG(WARNING,
            "Fork interception enabled. Re-initializing GekkoFS client...");

        // We must intentionally leak the old RPC/IPC engine to prevent
        // We must intentionally leak the old RPC/IPC engines to prevent
        // finalizing the parent's network connections
        for(const auto& engine : CTX->rpc_engines()) {
            auto* leaked_rpc_engine =
                new std::shared_ptr<thallium::engine>(CTX->rpc_engine());
                    new std::shared_ptr<thallium::engine>(engine);
            (void) leaked_rpc_engine;
        }
        auto* leaked_ipc_engine =
                new std::shared_ptr<thallium::engine>(CTX->ipc_engine());
        (void) leaked_rpc_engine;
        (void) leaked_ipc_engine;

        CTX->clear_hosts();