#include <sanitizer/lsan_interface.h>
#endif
-#define DEFAULT_TASKS_MAX ((TasksMax) { 15U, 100U }) /* 15% */
-
static enum {
ACTION_RUN,
ACTION_HELP,
arg_service_watchdogs = true;
unit_defaults_done(&arg_defaults);
+ unit_defaults_init(&arg_defaults, arg_runtime_scope);
- arg_defaults = (UnitDefaults) {
- .std_output = EXEC_OUTPUT_JOURNAL,
- .std_error = EXEC_OUTPUT_INHERIT,
- .restart_usec = DEFAULT_RESTART_USEC,
- .timeout_start_usec = manager_default_timeout(arg_runtime_scope),
- .timeout_stop_usec = manager_default_timeout(arg_runtime_scope),
- .timeout_abort_usec = manager_default_timeout(arg_runtime_scope),
- .timeout_abort_set = false,
- .device_timeout_usec = manager_default_timeout(arg_runtime_scope),
- .start_limit_interval = DEFAULT_START_LIMIT_INTERVAL,
- .start_limit_burst = DEFAULT_START_LIMIT_BURST,
-
- /* On 4.15+ with unified hierarchy, CPU accounting is essentially free as it doesn't require the CPU
- * controller to be enabled, so the default is to enable it unless we got told otherwise. */
- .cpu_accounting = cpu_accounting_is_cheap(),
- .memory_accounting = MEMORY_ACCOUNTING_DEFAULT,
- .io_accounting = false,
- .blockio_accounting = false,
- .tasks_accounting = true,
- .ip_accounting = false,
-
- .tasks_max = DEFAULT_TASKS_MAX,
- .timer_accuracy_usec = 1 * USEC_PER_MINUTE,
-
- .memory_pressure_watch = CGROUP_PRESSURE_WATCH_AUTO,
- .memory_pressure_threshold_usec = MEMORY_PRESSURE_DEFAULT_THRESHOLD_USEC,
-
- .oom_policy = OOM_STOP,
- .oom_score_adjust_set = false,
- };
arg_runtime_watchdog = 0;
arg_reboot_watchdog = 10 * USEC_PER_MINUTE;
arg_kexec_watchdog = 0;
/* How many units and jobs to process of the bus queue before returning to the event loop. */
#define MANAGER_BUS_MESSAGE_BUDGET 100U
+#define DEFAULT_TASKS_MAX ((TasksMax) { 15U, 100U }) /* 15% */
+
static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata);
static int manager_dispatch_cgroups_agent_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata);
static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata);
.status_unit_format = STATUS_UNIT_FORMAT_DEFAULT,
- .defaults = {
- .timer_accuracy_usec = USEC_PER_MINUTE,
- .memory_accounting = MEMORY_ACCOUNTING_DEFAULT,
- .tasks_accounting = true,
- .tasks_max = TASKS_MAX_UNSET,
- .timeout_start_usec = manager_default_timeout(runtime_scope),
- .timeout_stop_usec = manager_default_timeout(runtime_scope),
- .restart_usec = DEFAULT_RESTART_USEC,
- .device_timeout_usec = manager_default_timeout(runtime_scope),
- .oom_policy = OOM_STOP,
- .memory_pressure_watch = CGROUP_PRESSURE_WATCH_AUTO,
- .memory_pressure_threshold_usec = USEC_INFINITY,
- },
-
.original_log_level = -1,
.original_log_target = _LOG_TARGET_INVALID,
},
};
+ unit_defaults_init(&m->defaults, runtime_scope);
+
#if ENABLE_EFI
if (MANAGER_IS_SYSTEM(m) && detect_container() <= 0)
boot_timestamps(m->timestamps + MANAGER_TIMESTAMP_USERSPACE,
return s;
}
+void unit_defaults_init(UnitDefaults *defaults, RuntimeScope scope) {
+ assert(defaults);
+ assert(scope >= 0);
+ assert(scope < _RUNTIME_SCOPE_MAX);
+
+ *defaults = (UnitDefaults) {
+ .std_output = EXEC_OUTPUT_JOURNAL,
+ .std_error = EXEC_OUTPUT_INHERIT,
+ .restart_usec = DEFAULT_RESTART_USEC,
+ .timeout_start_usec = manager_default_timeout(scope),
+ .timeout_stop_usec = manager_default_timeout(scope),
+ .timeout_abort_usec = manager_default_timeout(scope),
+ .timeout_abort_set = false,
+ .device_timeout_usec = manager_default_timeout(scope),
+ .start_limit_interval = DEFAULT_START_LIMIT_INTERVAL,
+ .start_limit_burst = DEFAULT_START_LIMIT_BURST,
+
+ /* On 4.15+ with unified hierarchy, CPU accounting is essentially free as it doesn't require the CPU
+ * controller to be enabled, so the default is to enable it unless we got told otherwise. */
+ .cpu_accounting = cpu_accounting_is_cheap(),
+ .memory_accounting = MEMORY_ACCOUNTING_DEFAULT,
+ .io_accounting = false,
+ .blockio_accounting = false,
+ .tasks_accounting = true,
+ .ip_accounting = false,
+
+ .tasks_max = DEFAULT_TASKS_MAX,
+ .timer_accuracy_usec = 1 * USEC_PER_MINUTE,
+
+ .memory_pressure_watch = CGROUP_PRESSURE_WATCH_AUTO,
+ .memory_pressure_threshold_usec = MEMORY_PRESSURE_DEFAULT_THRESHOLD_USEC,
+
+ .oom_policy = OOM_STOP,
+ .oom_score_adjust_set = false,
+ };
+}
+
void unit_defaults_done(UnitDefaults *defaults) {
assert(defaults);