Skip to content

Commit 64e0774

Browse files
committed
fix: show UAC warning only when REALTIME priority.
1 parent 85f2896 commit 64e0774

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/helpers.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ std::string getLastWindowsErrorMsg(DWORD error_id)
151151

152152
bool setProcessPriority(pprocess_t& process, DWORD priority)
153153
{
154+
if (!isProcessElevated() && priority == REALTIME_PRIORITY_CLASS)
155+
{
156+
URCL_LOG_WARN("Process is not running with elevated privileges (UAC). "
157+
"REALTIME_PRIORITY_CLASS may fail. Try 'Run as Administrator'.");
158+
}
159+
154160
if (!::SetPriorityClass(process, priority))
155161
{
156162
DWORD err = GetLastError();
@@ -332,13 +338,7 @@ bool setThreadAffinity(pthread_t& thread, const cpu_set_t& cpuset)
332338
bool setFiFoScheduling(pthread_t& thread, int priority)
333339
{
334340
#ifdef _WIN32
335-
336-
if (!isProcessElevated())
337-
{
338-
URCL_LOG_WARN("Process is not running with elevated privileges (UAC). "
339-
"REALTIME_PRIORITY_CLASS may fail. Try 'Run as Administrator'.");
340-
}
341-
pprocess_t process = ::GetCurrentProcess();
341+
pprocess_t process = pprocess_self();
342342

343343
if (!setProcessPriority(process, REALTIME_PRIORITY_CLASS))
344344
{

0 commit comments

Comments
 (0)