Commit 03fae018 authored by Lennart Poettering's avatar Lennart Poettering
Browse files

uniformly suffix time span properties with their unit

parent 393a2f9b
......@@ -41,10 +41,12 @@
* get rid of Subscribe() in systemctl
* Unify NS, USec, NSec, Sec suffixes in properties, use format_timespan
* use format_timespan where applicable
* Turn around negative options
* Add missing man pages: update systemd.1, finish daemon.7
External:
* patch /etc/init.d/functions with:
......
......@@ -497,13 +497,19 @@
</varlistentry>
<varlistentry>
<term><varname>TimerSlackNS=</varname></term>
<term><varname>TimerSlackNSec=</varname></term>
<listitem><para>Sets the timer slack
in nanoseconds for the executed
processes The timer slack controls the accuracy
of wake-ups triggered by timers. See
processes The timer slack controls the
accuracy of wake-ups triggered by
timers. See
<citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
for more information.</para></listitem>
for more information. Note that in
contrast to most other time span
definitions this value is takes a
nano-seconds integer and does not
understand any other
units.</para></listitem>
</varlistentry>
<varlistentry>
......
......@@ -99,27 +99,27 @@
<variablelist>
<varlistentry>
<term><varname>OnActive=</varname></term>
<term><varname>OnBootup=</varname></term>
<term><varname>OnStartup=</varname></term>
<term><varname>OnUnitActive=</varname></term>
<term><varname>OnUnitInactive=</varname></term>
<term><varname>OnActiveSec=</varname></term>
<term><varname>OnBootSec=</varname></term>
<term><varname>OnStartupSec=</varname></term>
<term><varname>OnUnitActiveSec=</varname></term>
<term><varname>OnUnitInactiveSec=</varname></term>
<listitem><para>Defines timers
relative to different starting points:
<varname>OnActive=</varname> defines a
<varname>OnActiveSec=</varname> defines a
timer relative to the moment the timer
itself is
activated. <varname>OnBootup=</varname>
activated. <varname>OnBootSec=</varname>
defines a timer relative to when the
machine was booted
up. <varname>OnStartup=</varname>
up. <varname>OnStartupSec=</varname>
defines a timer relative to when
systemd was
started. <varname>OnUnitActive=</varname>
started. <varname>OnUnitActiveSec=</varname>
defines a timer relative to when the
unit the timer is activating was last
activated. <varname>OnUnitInactive=</varname>
activated. <varname>OnUnitInactiveSec=</varname>
defines a timer relative to when the
unit the timer is activating was last
deactivated.</para>
......@@ -127,8 +127,8 @@
<para>Multiple directives may be
combined of the same and of different
types. For example, by combining
<varname>OnBoot=</varname> and
<varname>OnUnitActive=</varname> it is
<varname>OnBootSec=</varname> and
<varname>OnUnitActiveSec=</varname> it is
possible to define a timer that
elapses in regular intervals and
activates a specific service each
......@@ -136,17 +136,17 @@
<para>The arguments to the directives
are time spans configured in
seconds. Example: "OnBoot=50" means
seconds. Example: "OnBootSec=50" means
50s after boot-up. The argument may
also include time units. Example:
"OnBoot=5h 30min" means 5 hours and 30
"OnBootSec=5h 30min" means 5 hours and 30
minutes after boot-up. For details
about the syntax of time spans see
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
<para>If a timer configured with
<varname>OnBootup=</varname> or
<varname>OnStartup=</varname> is
<varname>OnBootSec=</varname> or
<varname>OnStartupSec=</varname> is
already in the past when the timer
unit is activated, it will immediately
elapse and the configured unit is
......
......@@ -171,7 +171,7 @@ int bus_execute_append_affinity(Manager *m, DBusMessageIter *i, const char *prop
return 0;
}
int bus_execute_append_timer_slack_ns(Manager *m, DBusMessageIter *i, const char *property, void *data) {
int bus_execute_append_timer_slack_nsec(Manager *m, DBusMessageIter *i, const char *property, void *data) {
ExecContext *c = data;
uint64_t u;
......@@ -180,8 +180,8 @@ int bus_execute_append_timer_slack_ns(Manager *m, DBusMessageIter *i, const char
assert(property);
assert(c);
if (c->timer_slack_ns_set)
u = (uint64_t) c->timer_slack_ns_set;
if (c->timer_slack_nsec_set)
u = (uint64_t) c->timer_slack_nsec;
else
u = (uint64_t) prctl(PR_GET_TIMERSLACK);
......
......@@ -115,7 +115,7 @@
{ interface, "CPUSchedulingPolicy", bus_execute_append_cpu_sched_policy, "i", &(context) }, \
{ interface, "CPUSchedulingPriority", bus_execute_append_cpu_sched_priority, "i", &(context) }, \
{ interface, "CPUAffinity", bus_execute_append_affinity,"ay", &(context) }, \
{ interface, "TimerSlackNS", bus_execute_append_timer_slack_ns, "t", &(context) }, \
{ interface, "TimerSlackNSec", bus_execute_append_timer_slack_nsec, "t", &(context) }, \
{ interface, "CPUSchedulingResetOnFork", bus_property_append_bool, "b", &(context).cpu_sched_reset_on_fork }, \
{ interface, "NonBlocking", bus_property_append_bool, "b", &(context).non_blocking }, \
{ interface, "StandardInput", bus_execute_append_input, "s", &(context).std_input }, \
......@@ -158,7 +158,7 @@ int bus_execute_append_ioprio(Manager *m, DBusMessageIter *i, const char *proper
int bus_execute_append_cpu_sched_policy(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_cpu_sched_priority(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_affinity(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_timer_slack_ns(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_timer_slack_nsec(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_capabilities(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_rlimits(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_execute_append_command(Manager *m, DBusMessageIter *u, const char *property, void *data);
......
......@@ -29,7 +29,7 @@
" <interface name=\"org.freedesktop.systemd1.Timer\">\n" \
" <property name=\"Unit\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Timers\" type=\"a(stt)\" access=\"read\"/>\n" \
" <property name=\"NextElapse\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"NextElapseUSec\" type=\"t\" access=\"read\"/>\n" \
" </interface>\n"
#define INTROSPECTION \
......@@ -57,13 +57,30 @@ static int bus_timer_append_timers(Manager *m, DBusMessageIter *i, const char *p
return -ENOMEM;
LIST_FOREACH(value, k, p->values) {
const char *t = timer_base_to_string(k->base);
char *buf;
const char *t;
size_t l;
bool b;
if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &t) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->value) ||
!dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->next_elapse) ||
!dbus_message_iter_close_container(&sub, &sub2))
t = timer_base_to_string(k->base);
assert(endswith(t, "Sec"));
/* s/Sec/USec/ */
l = strlen(t);
if (!(buf = new(char, l+2)))
return -ENOMEM;
memcpy(buf, t, l-3);
memcpy(buf+l-3, "USec", 5);
b = dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) &&
dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &buf) &&
dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->value) &&
dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->next_elapse) &&
dbus_message_iter_close_container(&sub, &sub2);
free(buf);
if (!b)
return -ENOMEM;
}
......@@ -76,9 +93,9 @@ static int bus_timer_append_timers(Manager *m, DBusMessageIter *i, const char *p
DBusHandlerResult bus_timer_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Timer", "Unit", bus_property_append_string, "s", u->timer.unit->meta.id },
{ "org.freedesktop.systemd1.Timer", "Timers", bus_timer_append_timers, "a(stt)", u },
{ "org.freedesktop.systemd1.Timer", "NextElapse", bus_property_append_usec, "t", &u->timer.next_elapse },
{ "org.freedesktop.systemd1.Timer", "Unit", bus_property_append_string, "s", u->timer.unit->meta.id },
{ "org.freedesktop.systemd1.Timer", "Timers", bus_timer_append_timers, "a(stt)", u },
{ "org.freedesktop.systemd1.Timer", "NextElapseUSec", bus_property_append_usec, "t", &u->timer.next_elapse },
{ NULL, NULL, NULL, NULL, NULL }
};
......
......@@ -1083,8 +1083,8 @@ int exec_spawn(ExecCommand *command,
goto fail;
}
if (context->timer_slack_ns_set)
if (prctl(PR_SET_TIMERSLACK, context->timer_slack_ns_set) < 0) {
if (context->timer_slack_nsec_set)
if (prctl(PR_SET_TIMERSLACK, context->timer_slack_nsec) < 0) {
r = EXIT_TIMERSLACK;
goto fail;
}
......@@ -1468,8 +1468,8 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
fputs("\n", f);
}
if (c->timer_slack_ns_set)
fprintf(f, "%sTimerSlackNS: %lu\n", prefix, c->timer_slack_ns);
if (c->timer_slack_nsec_set)
fprintf(f, "%sTimerSlackNSec: %lu\n", prefix, c->timer_slack_nsec);
fprintf(f,
"%sStandardInput: %s\n"
......
......@@ -95,7 +95,7 @@ struct ExecContext {
cpu_set_t *cpuset;
unsigned cpuset_ncpus;
unsigned long timer_slack_ns;
unsigned long timer_slack_nsec;
ExecInput std_input;
ExecOutput std_output;
......@@ -135,7 +135,7 @@ struct ExecContext {
bool nice_set:1;
bool ioprio_set:1;
bool cpu_sched_set:1;
bool timer_slack_ns_set:1;
bool timer_slack_nsec_set:1;
/* This is not exposed to the user but available
* internally. We need it to make sure that whenever we spawn
......
......@@ -857,7 +857,7 @@ static int config_parse_bounding_set(
return 0;
}
static int config_parse_timer_slack_ns(
static int config_parse_timer_slack_nsec(
const char *filename,
unsigned line,
const char *section,
......@@ -880,7 +880,7 @@ static int config_parse_timer_slack_ns(
return r;
}
c->timer_slack_ns = u;
c->timer_slack_nsec = u;
return 0;
}
......@@ -1373,7 +1373,7 @@ static void dump_items(FILE *f, const ConfigItem *items) {
{ config_parse_capabilities, "CAPABILITIES" },
{ config_parse_secure_bits, "SECUREBITS" },
{ config_parse_bounding_set, "BOUNDINGSET" },
{ config_parse_timer_slack_ns, "TIMERSLACK" },
{ config_parse_timer_slack_nsec, "TIMERSLACK" },
{ config_parse_limit, "LIMIT" },
{ config_parse_cgroup, "CGROUP [...]" },
{ config_parse_deps, "UNIT [...]" },
......@@ -1468,7 +1468,7 @@ static int load_from_path(Unit *u, const char *path) {
{ "Capabilities", config_parse_capabilities, &(context), section }, \
{ "SecureBits", config_parse_secure_bits, &(context), section }, \
{ "CapabilityBoundingSetDrop", config_parse_bounding_set, &(context), section }, \
{ "TimerSlackNS", config_parse_timer_slack_ns, &(context), section }, \
{ "TimerSlackNSec", config_parse_timer_slack_nsec,&(context), section }, \
{ "LimitCPU", config_parse_limit, &(context).rlimit[RLIMIT_CPU], section }, \
{ "LimitFSIZE", config_parse_limit, &(context).rlimit[RLIMIT_FSIZE], section }, \
{ "LimitDATA", config_parse_limit, &(context).rlimit[RLIMIT_DATA], section }, \
......@@ -1574,11 +1574,11 @@ static int load_from_path(Unit *u, const char *path) {
{ "What", config_parse_path, &u->swap.parameters_fragment.what, "Swap" },
{ "Priority", config_parse_int, &u->swap.parameters_fragment.priority, "Swap" },
{ "OnActive", config_parse_timer, &u->timer, "Timer" },
{ "OnBoot", config_parse_timer, &u->timer, "Timer" },
{ "OnStartup", config_parse_timer, &u->timer, "Timer" },
{ "OnUnitActive", config_parse_timer, &u->timer, "Timer" },
{ "OnUnitInactive", config_parse_timer, &u->timer, "Timer" },
{ "OnActiveSec", config_parse_timer, &u->timer, "Timer" },
{ "OnBootSec", config_parse_timer, &u->timer, "Timer" },
{ "OnStartupSec", config_parse_timer, &u->timer, "Timer" },
{ "OnUnitActiveSec", config_parse_timer, &u->timer, "Timer" },
{ "OnUnitInactiveSec", config_parse_timer, &u->timer, "Timer" },
{ "Unit", config_parse_timer_unit, &u->timer, "Timer" },
{ "PathExists", config_parse_path_spec, &u->path, "Path" },
......
......@@ -440,11 +440,11 @@ static const char* const timer_state_table[_TIMER_STATE_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(timer_state, TimerState);
static const char* const timer_base_table[_TIMER_BASE_MAX] = {
[TIMER_ACTIVE] = "OnActive",
[TIMER_BOOT] = "OnBoot",
[TIMER_STARTUP] = "OnStartup",
[TIMER_UNIT_ACTIVE] = "OnUnitActive",
[TIMER_UNIT_INACTIVE] = "OnUnitInactive"
[TIMER_ACTIVE] = "OnActiveSec",
[TIMER_BOOT] = "OnBootSec",
[TIMER_STARTUP] = "OnStartupSec",
[TIMER_UNIT_ACTIVE] = "OnUnitActiveSec",
[TIMER_UNIT_INACTIVE] = "OnUnitInactiveSec"
};
DEFINE_STRING_TABLE_LOOKUP(timer_base, TimerBase);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment