Browse Source

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>
Kai Krakow 6 years ago
parent
commit
d8231a2972
1 changed files with 6 additions and 1 deletions
  1. 6 1
      daemon/gamemode.c

+ 6 - 1
daemon/gamemode.c

@@ -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);
 	}