From 944c8993e889898cf5894b608571c39d974faa26 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 11 Aug 2020 01:12:48 -0700 Subject: [PATCH] Elevate priorities for the UDP relay threads --- miss/miss.cpp | 4 ++++ miss/relay.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/miss/miss.cpp b/miss/miss.cpp index d0f8810..0db1a1f 100644 --- a/miss/miss.cpp +++ b/miss/miss.cpp @@ -868,6 +868,10 @@ int Run() ResetLogFile(); + // Bump the process priority class to above normal. The UDP relay threads will + // further raise their own thread priorities to avoid preemption by other activity. + SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); + // Create the UDP alternate port relays for (int i = 0; i < ARRAYSIZE(k_Ports); i++) { if (k_Ports[i].proto == IPPROTO_UDP) { diff --git a/miss/relay.cpp b/miss/relay.cpp index 1f2599a..a2465a4 100644 --- a/miss/relay.cpp +++ b/miss/relay.cpp @@ -21,6 +21,9 @@ UdpRelayThreadProc(LPVOID Context) PUDP_TUPLE tuple = (PUDP_TUPLE)Context; SOCKADDR_IN lastRemoteAddr; + // Ensure the relay threads aren't preempted by games or other CPU intensive activity + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); + RtlZeroMemory(&lastRemoteAddr, sizeof(lastRemoteAddr)); for (;;) {