Bug 1604106 - Don't assert on error conditions when changing the priority of a process on Windows r=bobowen

Differential Revision: https://phabricator.services.mozilla.com/D109088
This commit is contained in:
Gabriele Svelto 2021-03-25 15:41:23 +00:00
parent a4da022c74
commit 5d0d68e9d0

View File

@ -20,13 +20,6 @@ void SetProcessPriority(int aPid, ProcessPriority aPriority) {
nsAutoHandle processHandle(
::OpenProcess(PROCESS_SET_INFORMATION, FALSE, aPid));
#ifdef DEBUG
if (!processHandle) {
printf_stderr("::OpenProcess() failed with error %#08x\n",
::GetLastError());
}
#endif // DEBUG
MOZ_ASSERT(processHandle);
if (processHandle) {
DWORD priority = NORMAL_PRIORITY_CLASS;
if (aPriority == PROCESS_PRIORITY_BACKGROUND) {
@ -34,11 +27,12 @@ void SetProcessPriority(int aPid, ProcessPriority aPriority) {
} else if (aPriority == PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE) {
priority = BELOW_NORMAL_PRIORITY_CLASS;
}
::SetPriorityClass(processHandle, priority);
}
HAL_LOG("WindowsProcessPriority - priority set to %d for pid %d\n", aPriority,
aPid);
if (::SetPriorityClass(processHandle, priority)) {
HAL_LOG("WindowsProcessPriority - priority set to %d for pid %d\n",
aPriority, aPid);
}
}
}
} // namespace hal_impl