MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / BeginShutdown

Method BeginShutdown

src/platform/linux/cloud_hooks.cpp:921–961  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

919}
920
921void CloudHooks::BeginShutdown() {
922 g_shuttingDown.store(true, std::memory_order_release);
923 SchemaFetch::Shutdown();
924 RecvPktHook::Remove();
925 GamesPlayedHook::Remove();
926 LivePlaytime::RemoveUserCapture();
927 for (int i = 0; i < 300 && g_hookRefCount.load(std::memory_order_acquire) > 0; ++i)
928 usleep(10000); // 10ms, up to 3s total
929
930 // Join the poller before statics are destroyed. Wait bounded on its exit
931 // signal: join() if it reached its end (instant), else detach if wedged in
932 // curl rather than hang Steam's shutdown. See g_cloudPollerThread.
933 if (g_cloudPollerThread.joinable()) {
934 {
935 std::unique_lock<std::mutex> lk(g_pollerExitMtx);
936 g_pollerExitCv.wait_for(lk, std::chrono::seconds(5),
937 [] { return g_pollerExited.load(std::memory_order_acquire); });
938 }
939 if (g_pollerExited.load(std::memory_order_acquire)) {
940 g_cloudPollerThread.join();
941 } else {
942 LOG("[CloudHooks] poller wedged in network call -- detaching");
943 g_cloudPollerThread.detach();
944 }
945 }
946
947 // Same bounded-join discipline for the background seed thread.
948 if (g_seedThread.joinable()) {
949 {
950 std::unique_lock<std::mutex> lk(g_seedExitMtx);
951 g_seedExitCv.wait_for(lk, std::chrono::seconds(5),
952 [] { return g_seedExited.load(std::memory_order_acquire); });
953 }
954 if (g_seedExited.load(std::memory_order_acquire)) {
955 g_seedThread.join();
956 } else {
957 LOG("[CloudHooks] seed wedged in network call -- detaching");
958 g_seedThread.detach();
959 }
960 }
961}

Callers

nothing calls this directly

Calls 3

RemoveUserCaptureFunction · 0.85
ShutdownFunction · 0.70
RemoveFunction · 0.70

Tested by

no test coverage detected