summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-01 21:27:33 +0100
committerSven Eden <yamakuzure@gmx.net>2017-05-17 15:22:15 +0200
commit0f23ea0bef55d39322dcd3b73a7613efaa8e5b61 (patch)
tree14715ae3445c719a973da232471096e28071b6bb /src/shared
parent8d20404363bab2f394e583a0902ba4d3fdda453a (diff)
core: fix handling of AccuracyUSec and RandomDelayUSec bus properties
Clear up some confusion regarding the USec and Sec suffixes we use. In configuration files we usually use the Sec suffix, to indicate the implied time unit if none is specified. The respective bus properties however use the USec property, since they expose 64bit unsigned integers containing time in µs. Before this patch timer units exposed a bus property AccuracyUSec (which hence is the correct name) but when parsing transient property data would look for AccuracySec instead (which is incorrect). This patch ensures we look for AccuracySec correctly, but keeps the code for AccuracyUSec in place for compatibility, but adds a warning to ensure that apps are updated to use the right property.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-util.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index c12795d1f..5b7b48baf 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -1454,18 +1454,22 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
return 0;
- } else if (streq(field, "RandomizedDelaySec")) {
+ } else if (STR_IN_SET(field, "AccuracySec", "RandomizedDelaySec")) {
+ char *n;
usec_t t;
-
+ size_t l;
r = parse_sec(eq, &t);
if (r < 0)
- return log_error_errno(r, "Failed to parse RandomizedDelaySec= parameter: %s", eq);
+ return log_error_errno(r, "Failed to parse %s= parameter: %s", field, eq);
- r = sd_bus_message_append_basic(m, SD_BUS_TYPE_STRING, "RandomizedDelayUSec");
- if (r < 0)
- return bus_log_create_error(r);
+ l = strlen(field);
+ n = newa(char, l + 2);
+ if (!n)
+ return log_oom();
- r = sd_bus_message_append(m, "v", "t", t);
+ /* Change suffix Sec → USec */
+ strcpy(mempcpy(n, field, l - 3), "USec");
+ r = sd_bus_message_append(m, "sv", n, "t", t);
if (r < 0)
return bus_log_create_error(r);
@@ -1741,16 +1745,6 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
r = sd_bus_message_append(m, "v", "i", sig);
- } else if (streq(field, "AccuracySec")) {
- usec_t u;
-
- r = parse_sec(eq, &u);
- if (r < 0) {
- log_error("Failed to parse %s value %s", field, eq);
- return -EINVAL;
- }
-
- r = sd_bus_message_append(m, "v", "t", u);
} else if (streq(field, "TimerSlackNSec")) {
nsec_t n;