mirror of
https://github.com/systemd/systemd.git
synced 2025-03-23 10:50:16 +03:00
Merge pull request #6931 from poettering/job-timeout-sec
This commit is contained in:
commit
c05f3c8ff8
@ -1082,7 +1082,11 @@ int parse_sec(const char *t, usec_t *usec) {
|
||||
}
|
||||
|
||||
int parse_sec_fix_0(const char *t, usec_t *usec) {
|
||||
assert(t);
|
||||
assert(usec);
|
||||
|
||||
t += strspn(t, WHITESPACE);
|
||||
|
||||
if (streq(t, "0")) {
|
||||
*usec = USEC_INFINITY;
|
||||
return 0;
|
||||
|
@ -209,8 +209,8 @@ Unit.OnFailureJobMode, config_parse_job_mode, 0,
|
||||
Unit.OnFailureIsolate, config_parse_job_mode_isolate, 0, offsetof(Unit, on_failure_job_mode)
|
||||
Unit.IgnoreOnIsolate, config_parse_bool, 0, offsetof(Unit, ignore_on_isolate)
|
||||
Unit.IgnoreOnSnapshot, config_parse_warn_compat, DISABLED_LEGACY, 0
|
||||
Unit.JobTimeoutSec, config_parse_sec_fix_0, 0, offsetof(Unit, job_timeout)
|
||||
Unit.JobRunningTimeoutSec, config_parse_sec_fix_0, 0, offsetof(Unit, job_running_timeout)
|
||||
Unit.JobTimeoutSec, config_parse_job_timeout_sec, 0, 0
|
||||
Unit.JobRunningTimeoutSec, config_parse_job_running_timeout_sec, 0, 0
|
||||
Unit.JobTimeoutAction, config_parse_emergency_action, 0, offsetof(Unit, job_timeout_action)
|
||||
Unit.JobTimeoutRebootArgument, config_parse_unit_string_printf, 0, offsetof(Unit, job_timeout_reboot_arg)
|
||||
Unit.StartLimitIntervalSec, config_parse_sec, 0, offsetof(Unit, start_limit.interval)
|
||||
|
@ -4145,6 +4145,78 @@ int config_parse_protect_system(
|
||||
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_keyring_mode, exec_keyring_mode, ExecKeyringMode, "Failed to parse keyring mode");
|
||||
|
||||
int config_parse_job_timeout_sec(
|
||||
const char* unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
Unit *u = data;
|
||||
usec_t usec;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(u);
|
||||
|
||||
r = parse_sec_fix_0(rvalue, &usec);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse JobTimeoutSec= parameter, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If the user explicitly changed JobTimeoutSec= also change JobRunningTimeoutSec=, for compatibility with old
|
||||
* versions. If JobRunningTimeoutSec= was explicitly set, avoid this however as whatever the user picked should
|
||||
* count. */
|
||||
|
||||
if (!u->job_running_timeout_set)
|
||||
u->job_running_timeout = usec;
|
||||
|
||||
u->job_timeout = usec;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_job_running_timeout_sec(
|
||||
const char* unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
Unit *u = data;
|
||||
usec_t usec;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(u);
|
||||
|
||||
r = parse_sec_fix_0(rvalue, &usec);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse JobRunningTimeoutSec= parameter, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u->job_running_timeout = usec;
|
||||
u->job_running_timeout_set = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FOLLOW_MAX 8
|
||||
|
||||
static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
|
||||
|
@ -118,6 +118,8 @@ int config_parse_user_group_strv(const char *unit, const char *filename, unsigne
|
||||
int config_parse_restrict_namespaces(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_bind_paths(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_exec_keyring_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_job_timeout_sec(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
int config_parse_job_running_timeout_sec(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||
|
||||
/* gperf prototypes */
|
||||
const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
|
||||
|
@ -123,6 +123,7 @@ struct Unit {
|
||||
/* Job timeout and action to take */
|
||||
usec_t job_timeout;
|
||||
usec_t job_running_timeout;
|
||||
bool job_running_timeout_set:1;
|
||||
EmergencyAction job_timeout_action;
|
||||
char *job_timeout_reboot_arg;
|
||||
|
||||
|
@ -209,8 +209,10 @@ int generator_write_timeouts(
|
||||
|
||||
return write_drop_in_format(dir, unit, 50, "device-timeout",
|
||||
"# Automatically generated by %s\n\n"
|
||||
"[Unit]\nJobRunningTimeoutSec=%s",
|
||||
program_invocation_short_name, timeout);
|
||||
"[Unit]\n"
|
||||
"JobRunningTimeoutSec=%s",
|
||||
program_invocation_short_name,
|
||||
timeout);
|
||||
}
|
||||
|
||||
int generator_write_device_deps(
|
||||
@ -262,6 +264,10 @@ int generator_write_initrd_root_device_deps(const char *dir, const char *what) {
|
||||
|
||||
return write_drop_in_format(dir, SPECIAL_INITRD_ROOT_DEVICE_TARGET, 50, "root-device",
|
||||
"# Automatically generated by %s\n\n"
|
||||
"[Unit]\nRequires=%s\nAfter=%s",
|
||||
program_invocation_short_name, unit, unit);
|
||||
"[Unit]\n"
|
||||
"Requires=%s\n"
|
||||
"After=%s",
|
||||
program_invocation_short_name,
|
||||
unit,
|
||||
unit);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user