summaryrefslogtreecommitdiff
path: root/src/dbus-execute.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-08-31 01:33:39 +0200
committerLennart Poettering <lennart@poettering.net>2010-08-31 01:33:43 +0200
commitdd6c17b1595ff8a78ebae6cf571fd222c80bfd17 (patch)
tree1c3409f81d533008deeb3725b27b1f2de57e204a /src/dbus-execute.c
parent71916d3fff97c6026b5e8bb2c8e4169ab14dc3ad (diff)
exec: replace OOMAdjust= by OOMScoreAdjust= to follow new kernel interface
This replaces OOMAdjust= by OOMScoreAdjust= in the config files, breaking compatibility with older unit files. However, this keeps compat with older kernels which lack the new OOM rework.
Diffstat (limited to 'src/dbus-execute.c')
-rw-r--r--src/dbus-execute.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/dbus-execute.c b/src/dbus-execute.c
index 4f8a3da0d1..cdc15b25ce 100644
--- a/src/dbus-execute.c
+++ b/src/dbus-execute.c
@@ -33,7 +33,7 @@ DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_kill_mode, kill_mode, KillMod
DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_input, exec_input, ExecInput);
DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_output, exec_output, ExecOutput);
-int bus_execute_append_oom_adjust(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_execute_append_oom_score_adjust(Manager *m, DBusMessageIter *i, const char *property, void *data) {
ExecContext *c = data;
int32_t n;
@@ -42,15 +42,23 @@ int bus_execute_append_oom_adjust(Manager *m, DBusMessageIter *i, const char *pr
assert(property);
assert(c);
- if (c->oom_adjust_set)
- n = c->oom_adjust;
+ if (c->oom_score_adjust_set)
+ n = c->oom_score_adjust;
else {
char *t;
n = 0;
- if (read_one_line_file("/proc/self/oom_adj", &t) >= 0) {
+ if (read_one_line_file("/proc/self/oom_score_adj", &t) >= 0) {
safe_atoi(t, &n);
free(t);
+ } else if (read_one_line_file("/proc/self/oom_adj", &t) >= 0) {
+ safe_atoi(t, &n);
+ free(t);
+
+ if (n == OOM_ADJUST_MAX)
+ n = OOM_SCORE_ADJ_MAX;
+ else
+ n = (n * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE;
}
}