| 919 | } |
| 920 | |
| 921 | void 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 | } |
nothing calls this directly
no test coverage detected