Skip to content

Commit

Permalink
Add workaround to ThreadWatchdog to prevent exit during nwsync.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhett12321 committed Jul 3, 2023
1 parent 3f6343b commit 34540dc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Plugins/ThreadWatchdog/ThreadWatchdog.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ThreadWatchdog.hpp"
#include "API/CNWSModule.hpp"
#include "API/Functions.hpp"
#include "API/CServerExoAppInternal.hpp"

Expand All @@ -24,12 +25,18 @@ static Hooks::Hook s_MainLoopHook;
ThreadWatchdog::ThreadWatchdog(Services::ProxyServiceList* services)
: Plugin(services)
{
s_MainLoopHook = Hooks::HookFunction(&CServerExoAppInternal::MainLoop,
&MainLoopUpdate, Hooks::Order::Earliest);

s_watchdogPeriod = Config::Get<uint32_t>("PERIOD", 15);
// Default to effectively infinite
s_watchdogKillThreshold = Config::Get<uint32_t>("KILL_THRESHOLD", ~0);

static Hooks::Hook loadModuleStartHook = Hooks::HookFunction(&CNWSModule::LoadModuleStart,
+[](CNWSModule *pModule, CExoString param_1, int param_2, int param_3, const NWSync::Advertisement &param_4) -> uint32_t
{
s_MainLoopHook = Hooks::HookFunction(&CServerExoAppInternal::MainLoop,
&MainLoopUpdate, Hooks::Order::Earliest);

return loadModuleStartHook->CallOriginal<uint32_t>(pModule, param_1, param_2, param_3, param_4);
}, Hooks::Order::Late);
}

ThreadWatchdog::~ThreadWatchdog()
Expand Down

0 comments on commit 34540dc

Please sign in to comment.