summaryrefslogtreecommitdiff
path: root/src/core/job.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-04 00:35:43 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-04 00:35:43 +0100
commit7a7821c878a6ddfb2e79268bb1cd8f7662a9b8f8 (patch)
tree491907630dcf974ae630529302e4fe87f658ddc3 /src/core/job.c
parent8e5de09f442874bed2a8889aa28739d2a516b094 (diff)
core: rework job_get_timeout() to use usec_t and handle USEC_INFINITY time events correctly
Diffstat (limited to 'src/core/job.c')
-rw-r--r--src/core/job.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/core/job.c b/src/core/job.c
index 1dcb872019..b1737c8110 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -1165,10 +1165,10 @@ void job_shutdown_magic(Job *j) {
asynchronous_sync();
}
-int job_get_timeout(Job *j, uint64_t *timeout) {
+int job_get_timeout(Job *j, usec_t *timeout) {
+ usec_t x = USEC_INFINITY, y = USEC_INFINITY;
Unit *u = j->unit;
- uint64_t x = -1, y = -1;
- int r = 0, q = 0;
+ int r;
assert(u);
@@ -1176,20 +1176,18 @@ int job_get_timeout(Job *j, uint64_t *timeout) {
r = sd_event_source_get_time(j->timer_event_source, &x);
if (r < 0)
return r;
- r = 1;
}
if (UNIT_VTABLE(u)->get_timeout) {
- q = UNIT_VTABLE(u)->get_timeout(u, &y);
- if (q < 0)
- return q;
+ r = UNIT_VTABLE(u)->get_timeout(u, &y);
+ if (r < 0)
+ return r;
}
- if (r == 0 && q == 0)
+ if (x == USEC_INFINITY && y == USEC_INFINITY)
return 0;
*timeout = MIN(x, y);
-
return 1;
}