chiark / gitweb /
core: add new RandomSec= setting for time units
authorLennart Poettering <lennart@poettering.net>
Wed, 18 Nov 2015 12:37:30 +0000 (13:37 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 17 May 2017 13:22:14 +0000 (15:22 +0200)
This allows configuration of a random time on top of the elapse events,
in order to spread time events in a network evenly across a range.

src/shared/bus-util.c

index 62c32a64d230e3d82f88ecb2149c77461955220a..8b79883727e07a144f4976d52fa5da9968d503ab 100644 (file)
@@ -1453,6 +1453,23 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                         return bus_log_create_error(r);
 
                 return 0;
+
+        } else if (streq(field, "RandomSec")) {
+                usec_t t;
+
+                r = parse_sec(eq, &t);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to parse RandomSec= parameter: %s", eq);
+
+                r = sd_bus_message_append_basic(m, SD_BUS_TYPE_STRING, "RandomUSec");
+                if (r < 0)
+                        return bus_log_create_error(r);
+
+                r = sd_bus_message_append(m, "v", "t", t);
+                if (r < 0)
+                        return bus_log_create_error(r);
+
+                return 0;
         }
 
         r = sd_bus_message_append_basic(m, SD_BUS_TYPE_STRING, field);