summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-02-01 18:06:40 +0100
committerTom Gundersen <teg@jklm.no>2015-02-02 11:57:52 +0100
commitc4f1aff2306e4fb10efeda75f7015e5d043d4e8d (patch)
treeab20a34e1fcb67f45930dcdb538ce0c5be2aa791
parent5d8689d749ffc50ade3d5c8598c1d3d11f5240f2 (diff)
sd-event: treat NULL callback for timer events like sig events
In both cases exit the event loop.
-rw-r--r--src/libsystemd/sd-event/sd-event.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index f9fa54d2e8..25089a0335 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -891,6 +891,12 @@ static int event_setup_timer_fd(
return 0;
}
+static int time_exit_callback(sd_event_source *s, uint64_t usec, void *userdata) {
+ assert(s);
+
+ return sd_event_exit(sd_event_source_get_event(s), PTR_TO_INT(userdata));
+}
+
_public_ int sd_event_add_time(
sd_event *e,
sd_event_source **ret,
@@ -908,10 +914,12 @@ _public_ int sd_event_add_time(
assert_return(e, -EINVAL);
assert_return(usec != (uint64_t) -1, -EINVAL);
assert_return(accuracy != (uint64_t) -1, -EINVAL);
- assert_return(callback, -EINVAL);
assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
assert_return(!event_pid_changed(e), -ECHILD);
+ if (!callback)
+ callback = time_exit_callback;
+
type = clock_to_event_source_type(clock);
assert_return(type >= 0, -ENOTSUP);