diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-06-18 05:18:41 -0400 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-06-18 11:18:41 +0200 |
commit | d4bf82fcac576d9dfbc1b837995a780dc851cd4c (patch) | |
tree | c1fea2de6b02f8597ac04089342c9c53541a0459 /src/core | |
parent | f1fccf53229516f99137d5d80ed5b92e586458e6 (diff) | |
download | systemd-d4bf82fcac576d9dfbc1b837995a780dc851cd4c.tar.gz |
pid1: properly encode infinity when writing CPUQuota snippet (#6141)
We would write
[Slice]
CPUQuota=1844674407370955%
which is (numerically) correct, but it seems better to just write
[Slice]
CPUQuota=
which is interpreted as USEC_INFINITY by the parser in config_parse_cpu_quota().
Fixes #5965.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/dbus-cgroup.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index c4067a95bf..12d3ca076b 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -407,7 +407,15 @@ int bus_cgroup_set_property( if (mode != UNIT_CHECK) { c->cpu_quota_per_sec_usec = u64; unit_invalidate_cgroup(u, CGROUP_MASK_CPU); - unit_write_drop_in_private_format(u, mode, "CPUQuota", "CPUQuota=%0.f%%", (double) (c->cpu_quota_per_sec_usec / 10000)); + if (c->cpu_quota_per_sec_usec == USEC_INFINITY) + unit_write_drop_in_private_format(u, mode, "CPUQuota", + "CPUQuota="); + else + /* config_parse_cpu_quota() requires an integer, so + * truncating division is used on purpose here. */ + unit_write_drop_in_private_format(u, mode, "CPUQuota", + "CPUQuota=%0.f%%", + (double) (c->cpu_quota_per_sec_usec / 10000)); } return 1; |