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
s = SOCKET(data);
- if ((b = socket_address_bind_ipv6_only_from_string(rvalue)) < 0) {
+ b = socket_address_bind_ipv6_only_from_string(rvalue);
+ if (b < 0) {
int r;
- if ((r = parse_boolean(rvalue)) < 0) {
+ r = parse_boolean(rvalue);
+ if (r < 0) {
log_error("[%s:%u] Failed to parse bind IPv6 only value, ignoring: %s", filename, line, rvalue);
return 0;
}
e += ltype;
for (;;) {
+ int i;
char *w;
size_t l;
char *state;
if (rvalue[0] == 0)
break;
- if (rvalue[0] == '-') {
- ignore = true;
- rvalue ++;
- }
+ for (i = 0; i < 2; i++) {
+ if (rvalue[0] == '-' && !ignore) {
+ ignore = true;
+ rvalue ++;
+ }
- if (rvalue[0] == '@') {
- honour_argv0 = true;
- rvalue ++;
+ if (rvalue[0] == '@' && !honour_argv0) {
+ honour_argv0 = true;
+ rvalue ++;
+ }
}
if (*rvalue != '/') {
- log_error("[%s:%u] Invalid executable path in command line, ignoring: %s", filename, line, rvalue);
+ log_error("[%s:%u] Executable path is not absolute, ignoring: %s",
+ filename, line, rvalue);
return 0;
}
FOREACH_WORD_QUOTED(w, l, rvalue, state) {
if (strncmp(w, ";", MAX(l, 1U)) == 0)
break;
+ else if (strncmp(w, "\\;", MAX(l, 1U)) == 0)
+ w ++;
if (honour_argv0 && w == rvalue) {
assert(!path);
assert(rvalue);
assert(data);
- if ((x = ioprio_class_from_string(rvalue)) < 0) {
+ x = ioprio_class_from_string(rvalue);
+ if (x < 0) {
log_error("[%s:%u] Failed to parse IO scheduling class, ignoring: %s", filename, line, rvalue);
return 0;
}
assert(rvalue);
assert(data);
- if ((x = sched_policy_from_string(rvalue)) < 0) {
+ x = sched_policy_from_string(rvalue);
+ if (x < 0) {
log_error("[%s:%u] Failed to parse CPU scheduling policy, ignoring: %s", filename, line, rvalue);
return 0;
}
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;
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;
assert(rvalue);
assert(data);
- if ((x = ip_tos_from_string(rvalue)) < 0)
- if (safe_atoi(rvalue, &x) < 0) {
- log_error("[%s:%u] Failed to parse IP TOS value, ignoring: %s", filename, line, rvalue);
- return 0;
- }
+ x = ip_tos_from_string(rvalue);
+ if (x < 0) {
+ log_error("[%s:%u] Failed to parse IP TOS value, ignoring: %s", filename, line, rvalue);
+ return 0;
+ }
*ip_tos = x;
return 0;