run: can launch units with OOMScoreAdjust

This commit is contained in:
Evgeny Vereshchagin
2015-10-17 20:03:40 +00:00
parent 257b0719cb
commit 6b862936c7
2 changed files with 33 additions and 0 deletions
+18
View File
@@ -1186,6 +1186,24 @@ int bus_exec_context_set_transient_property(
return 1;
} else if (streq(name, "OOMScoreAdjust")) {
int oa;
r = sd_bus_message_read(message, "i", &oa);
if (r < 0)
return r;
if (!oom_score_adjust_is_valid(oa))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "OOM score adjust value out of range");
if (mode != UNIT_CHECK) {
c->oom_score_adjust = oa;
c->oom_score_adjust_set = true;
unit_write_drop_in_private_format(u, mode, name, "OOMScoreAdjust=%i\n", oa);
}
return 1;
} else if (rlimit_from_string(name) >= 0) {
uint64_t rl;
rlim_t x;
+15
View File
@@ -1665,6 +1665,21 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
}
r = sd_bus_message_append(m, "v", "t", n);
} else if (streq(field, "OOMScoreAdjust")) {
int oa;
r = safe_atoi(eq, &oa);
if (r < 0) {
log_error("Failed to parse %s value %s", field, eq);
return -EINVAL;
}
if (!oom_score_adjust_is_valid(oa)) {
log_error("OOM score adjust value out of range");
return -EINVAL;
}
r = sd_bus_message_append(m, "v", "i", oa);
} else {
log_error("Unknown assignment %s.", assignment);
return -EINVAL;