X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fload-fragment.c;h=6759255984288fe350101f0552bc46f2add75d2a;hp=b99e70e05a144de8b77f6e72345a83862a1c3e4f;hb=bb11271068ff34434f5b8cefd0c2c0bae5ed7fd1;hpb=0f67f1efae74e6d129338f1b63ede902b3d7e5ae diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index b99e70e05..675925598 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -4,6 +4,7 @@ This file is part of systemd. Copyright 2010 Lennart Poettering + Copyright 2012 Holger Hans Peter Freyther systemd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -689,6 +690,8 @@ int config_parse_exec_cpu_sched_policy( } c->cpu_sched_policy = x; + /* Moving to or from real-time policy? We need to adjust the priority */ + c->cpu_sched_priority = CLAMP(c->cpu_sched_priority, sched_get_priority_min(x), sched_get_priority_max(x)); c->cpu_sched_set = true; return 0; @@ -705,19 +708,28 @@ int config_parse_exec_cpu_sched_prio( void *userdata) { ExecContext *c = data; - int i; + int i, min, max; assert(filename); assert(lvalue); assert(rvalue); assert(data); - /* On Linux RR/FIFO have the same range */ - if (safe_atoi(rvalue, &i) < 0 || i < sched_get_priority_min(SCHED_RR) || i > sched_get_priority_max(SCHED_RR)) { + if (safe_atoi(rvalue, &i) < 0) { log_error("[%s:%u] Failed to parse CPU scheduling priority, ignoring: %s", filename, line, rvalue); return 0; } + + /* On Linux RR/FIFO range from 1 to 99 and OTHER/BATCH may only be 0 */ + min = sched_get_priority_min(c->cpu_sched_policy); + max = sched_get_priority_max(c->cpu_sched_policy); + + if (i < min || i > max) { + log_error("[%s:%u] CPU scheduling priority is out of range, ignoring: %s", filename, line, rvalue); + return 0; + } + c->cpu_sched_priority = i; c->cpu_sched_set = true;