diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-05-31 04:27:03 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-05-31 04:27:03 +0200 |
commit | d88a251b125f6e9178b9ca9ea47ab7da3234cb58 (patch) | |
tree | 6c982e764f991ed9169bd4fb53a601dcd295795b /src/core | |
parent | 256425cc10d74c13602527eb86b4ba0938964565 (diff) |
util: introduce a proper nsec_t and make use of it where appropriate
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/dbus-execute.c | 2 | ||||
-rw-r--r-- | src/core/execute.c | 5 | ||||
-rw-r--r-- | src/core/execute.h | 3 | ||||
-rw-r--r-- | src/core/load-fragment-gperf.gperf.m4 | 2 | ||||
-rw-r--r-- | src/core/load-fragment.c | 30 | ||||
-rw-r--r-- | src/core/load-fragment.h | 1 |
6 files changed, 7 insertions, 36 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index ef55ef12b9..f1a9da0c57 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -216,7 +216,7 @@ int bus_execute_append_timer_slack_nsec(DBusMessageIter *i, const char *property assert(property); assert(c); - if (c->timer_slack_nsec_set) + if (c->timer_slack_nsec != (nsec_t) -1) u = (uint64_t) c->timer_slack_nsec; else u = (uint64_t) prctl(PR_GET_TIMERSLACK); diff --git a/src/core/execute.c b/src/core/execute.c index 9c2006ebc7..3ef4eafa7f 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1183,7 +1183,7 @@ int exec_spawn(ExecCommand *command, goto fail_child; } - if (context->timer_slack_nsec_set) + if (context->timer_slack_nsec != (nsec_t) -1) if (prctl(PR_SET_TIMERSLACK, context->timer_slack_nsec) < 0) { err = -errno; r = EXIT_TIMERSLACK; @@ -1494,6 +1494,7 @@ void exec_context_init(ExecContext *c) { c->send_sigkill = true; c->control_group_persistent = -1; c->ignore_sigpipe = true; + c->timer_slack_nsec = (nsec_t) -1; } void exec_context_done(ExecContext *c) { @@ -1739,7 +1740,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { fputs("\n", f); } - if (c->timer_slack_nsec_set) + if (c->timer_slack_nsec != (nsec_t) -1) fprintf(f, "%sTimerSlackNSec: %lu\n", prefix, c->timer_slack_nsec); fprintf(f, diff --git a/src/core/execute.h b/src/core/execute.h index 03c63d465a..6c68169a84 100644 --- a/src/core/execute.h +++ b/src/core/execute.h @@ -118,7 +118,7 @@ struct ExecContext { ExecOutput std_output; ExecOutput std_error; - unsigned long timer_slack_nsec; + nsec_t timer_slack_nsec; char *tcpwrap_name; @@ -178,7 +178,6 @@ struct ExecContext { bool nice_set:1; bool ioprio_set:1; bool cpu_sched_set:1; - bool timer_slack_nsec_set:1; }; int exec_spawn(ExecCommand *command, diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4 index 6f2a0d63ef..0e21e8165f 100644 --- a/src/core/load-fragment-gperf.gperf.m4 +++ b/src/core/load-fragment-gperf.gperf.m4 @@ -47,7 +47,7 @@ $1.SyslogLevelPrefix, config_parse_bool, 0, $1.Capabilities, config_parse_exec_capabilities, 0, offsetof($1, exec_context) $1.SecureBits, config_parse_exec_secure_bits, 0, offsetof($1, exec_context) $1.CapabilityBoundingSet, config_parse_bounding_set, 0, offsetof($1, exec_context.capability_bounding_set_drop) -$1.TimerSlackNSec, config_parse_exec_timer_slack_nsec, 0, offsetof($1, exec_context) +$1.TimerSlackNSec, config_parse_nsec, 0, offsetof($1, exec_context.timer_slack_nsec) $1.LimitCPU, config_parse_limit, RLIMIT_CPU, offsetof($1, exec_context.rlimit) $1.LimitFSIZE, config_parse_limit, RLIMIT_FSIZE, offsetof($1, exec_context.rlimit) $1.LimitDATA, config_parse_limit, RLIMIT_DATA, offsetof($1, exec_context.rlimit) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index ff6e13e599..2db1290db8 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -991,34 +991,6 @@ int config_parse_bounding_set( return 0; } -int config_parse_exec_timer_slack_nsec( - const char *filename, - unsigned line, - const char *section, - const char *lvalue, - int ltype, - const char *rvalue, - void *data, - void *userdata) { - - ExecContext *c = data; - unsigned long u; - - assert(filename); - assert(lvalue); - assert(rvalue); - assert(data); - - if (safe_atolu(rvalue, &u) < 0) { - log_error("[%s:%u] Failed to parse time slack value, ignoring: %s", filename, line, rvalue); - return 0; - } - - c->timer_slack_nsec = u; - - return 0; -} - int config_parse_limit( const char *filename, unsigned line, @@ -2449,7 +2421,6 @@ void unit_dump_config_items(FILE *f) { { config_parse_exec_capabilities, "CAPABILITIES" }, { config_parse_exec_secure_bits, "SECUREBITS" }, { config_parse_bounding_set, "BOUNDINGSET" }, - { config_parse_exec_timer_slack_nsec, "TIMERSLACK" }, { config_parse_limit, "LIMIT" }, { config_parse_unit_cgroup, "CGROUP [...]" }, { config_parse_unit_deps, "UNIT [...]" }, @@ -2468,6 +2439,7 @@ void unit_dump_config_items(FILE *f) { { config_parse_socket_bind, "SOCKETBIND" }, { config_parse_socket_bindtodevice, "NETWORKINTERFACE" }, { config_parse_usec, "SECONDS" }, + { config_parse_nsec, "NANOSECONDS" }, { config_parse_path_strv, "PATH [...]" }, { config_parse_unit_requires_mounts_for, "PATH [...]" }, { config_parse_exec_mount_flags, "MOUNTFLAG [...]" }, diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h index 6b382494aa..b412d3b2ea 100644 --- a/src/core/load-fragment.h +++ b/src/core/load-fragment.h @@ -57,7 +57,6 @@ int config_parse_exec_cpu_affinity(const char *filename, unsigned line, const ch int config_parse_exec_capabilities(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_exec_secure_bits(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_bounding_set(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); -int config_parse_exec_timer_slack_nsec(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_limit(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_unit_cgroup(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_sysv_priority(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |