path unit: add TriggerLimitBurst= and TriggerLimitIntervalSec=
Given there's now a default for these settings, also allow users to configure them, matching socket units
This commit is contained in:
@@ -49,6 +49,8 @@ const sd_bus_vtable bus_path_vtable[] = {
|
||||
SD_BUS_PROPERTY("MakeDirectory", "b", bus_property_get_bool, offsetof(Path, make_directory), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Path, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Path, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("TriggerLimitIntervalUSec", "t", bus_property_get_usec, offsetof(Path, trigger_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("TriggerLimitBurst", "u", bus_property_get_unsigned, offsetof(Path, trigger_limit.burst), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_VTABLE_END
|
||||
};
|
||||
|
||||
@@ -136,6 +138,12 @@ static int bus_path_set_transient_property(
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (streq(name, "TriggerLimitBurst"))
|
||||
return bus_set_transient_unsigned(u, name, &p->trigger_limit.burst, message, flags, error);
|
||||
|
||||
if (streq(name, "TriggerLimitIntervalUSec"))
|
||||
return bus_set_transient_usec(u, name, &p->trigger_limit.interval, message, flags, error);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -542,6 +542,8 @@ Path.DirectoryNotEmpty, config_parse_path_spec,
|
||||
Path.Unit, config_parse_trigger_unit, 0, 0
|
||||
Path.MakeDirectory, config_parse_bool, 0, offsetof(Path, make_directory)
|
||||
Path.DirectoryMode, config_parse_mode, 0, offsetof(Path, directory_mode)
|
||||
Path.TriggerLimitIntervalSec, config_parse_sec, 0, offsetof(Path, trigger_limit.interval)
|
||||
Path.TriggerLimitBurst, config_parse_unsigned, 0, offsetof(Path, trigger_limit.burst)
|
||||
{{ CGROUP_CONTEXT_CONFIG_ITEMS('Slice') }}
|
||||
{{ CGROUP_CONTEXT_CONFIG_ITEMS('Scope') }}
|
||||
{{ KILL_CONTEXT_CONFIG_ITEMS('Scope') }}
|
||||
|
||||
+18
-4
@@ -266,8 +266,8 @@ static void path_init(Unit *u) {
|
||||
|
||||
p->directory_mode = 0755;
|
||||
|
||||
p->trigger_limit.interval = 2 * USEC_PER_SEC;
|
||||
p->trigger_limit.burst = 200;
|
||||
p->trigger_limit.interval = USEC_INFINITY;
|
||||
p->trigger_limit.burst = UINT_MAX;
|
||||
}
|
||||
|
||||
void path_free_specs(Path *p) {
|
||||
@@ -356,6 +356,16 @@ static int path_add_trigger_dependencies(Path *p) {
|
||||
static int path_add_extras(Path *p) {
|
||||
int r;
|
||||
|
||||
assert(p);
|
||||
|
||||
/* To avoid getting pid1 in a busy-loop state (eg: failed condition on associated service),
|
||||
* set a default trigger limit if the user didn't specify any. */
|
||||
if (p->trigger_limit.interval == USEC_INFINITY)
|
||||
p->trigger_limit.interval = 2 * USEC_PER_SEC;
|
||||
|
||||
if (p->trigger_limit.burst == UINT_MAX)
|
||||
p->trigger_limit.burst = 200;
|
||||
|
||||
r = path_add_trigger_dependencies(p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -403,12 +413,16 @@ static void path_dump(Unit *u, FILE *f, const char *prefix) {
|
||||
"%sResult: %s\n"
|
||||
"%sUnit: %s\n"
|
||||
"%sMakeDirectory: %s\n"
|
||||
"%sDirectoryMode: %04o\n",
|
||||
"%sDirectoryMode: %04o\n"
|
||||
"%sTriggerLimitIntervalSec: %s\n"
|
||||
"%sTriggerLimitBurst: %u\n",
|
||||
prefix, path_state_to_string(p->state),
|
||||
prefix, path_result_to_string(p->result),
|
||||
prefix, trigger ? trigger->id : "n/a",
|
||||
prefix, yes_no(p->make_directory),
|
||||
prefix, p->directory_mode);
|
||||
prefix, p->directory_mode,
|
||||
prefix, FORMAT_TIMESPAN(p->trigger_limit.interval, USEC_PER_SEC),
|
||||
prefix, p->trigger_limit.burst);
|
||||
|
||||
LIST_FOREACH(spec, s, p->specs)
|
||||
path_spec_dump(s, f, prefix);
|
||||
|
||||
Reference in New Issue
Block a user