scheduler: Don't renice if already reniced

This is a heuristic to not apply a nice level if the user already did
that (or the process itself).

Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit is contained in:
Kai Krakow 2018-05-24 22:28:18 +02:00
parent 76ece2fc26
commit d8231a2972

View File

@ -179,7 +179,12 @@ static void game_mode_apply_scheduler(pid_t client)
{
LOG_MSG("Setting scheduling policies...\n");
if (setpriority(PRIO_PROCESS, (id_t)client, NICE_PRIORITY)) {
/*
* don't adjust priority if it was already adjusted
*/
if (getpriority(PRIO_PROCESS, (id_t)client) != 0) {
LOG_ERROR("Client [%d] already reniced, ignoring.\n", client);
} else if (setpriority(PRIO_PROCESS, (id_t)client, NICE_PRIORITY)) {
LOG_ERROR("Renicing client [%d] failed with error %d, ignoring.\n", client, errno);
}