diff options
author | Tom Gundersen <teg@jklm.no> | 2015-08-03 17:57:26 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-08-03 17:57:26 +0200 |
commit | 6934f402cded89a988e8d7f93bf0b7b4eb8f17f3 (patch) | |
tree | 0decd0bdddc5a9be1ea76ce38c756ec85e42ab94 /src/libsystemd/sd-event/sd-event.c | |
parent | 5ef9b2203e027da168b18d92045462422895565b (diff) | |
parent | 38a03f06a7393d2721c23f23f0589d2f6d0904af (diff) |
Merge pull request #843 from poettering/clock-boottime
sd-event: make sure sd_event_now() cannot fail
Diffstat (limited to 'src/libsystemd/sd-event/sd-event.c')
-rw-r--r-- | src/libsystemd/sd-event/sd-event.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 76964aa0cc..754fb7614e 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -2572,9 +2572,12 @@ _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) { assert_return(usec, -EINVAL); assert_return(!event_pid_changed(e), -ECHILD); - /* If we haven't run yet, just get the actual time */ - if (!dual_timestamp_is_set(&e->timestamp)) - return -ENODATA; + if (!dual_timestamp_is_set(&e->timestamp)) { + /* Implicitly fall back to now() if we never ran + * before and thus have no cached time. */ + *usec = now(clock); + return 1; + } switch (clock) { |