summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-24 02:49:09 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-24 02:58:41 +0100
commit6a0f1f6d5af7c7300d3db7a0ba2b068f8abd222b (patch)
tree37083cf4a7292fc4657372d034475e026693f969 /src/core
parentf66eeb6bb636f8061bf45e6e8e24761e87510800 (diff)
sd-event: rework API to support CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM, too
Diffstat (limited to 'src/core')
-rw-r--r--src/core/job.c14
-rw-r--r--src/core/manager.c7
-rw-r--r--src/core/mount.c7
-rw-r--r--src/core/scope.c7
-rw-r--r--src/core/service.c14
-rw-r--r--src/core/socket.c7
-rw-r--r--src/core/swap.c7
-rw-r--r--src/core/timer.c14
8 files changed, 66 insertions, 11 deletions
diff --git a/src/core/job.c b/src/core/job.c
index 8e98bd93ab..35a9de6ee3 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -873,7 +873,12 @@ int job_start_timer(Job *j) {
if (j->unit->job_timeout <= 0)
return 0;
- r = sd_event_add_monotonic(j->manager->event, &j->timer_event_source, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j);
+ r = sd_event_add_time(
+ j->manager->event,
+ &j->timer_event_source,
+ CLOCK_MONOTONIC,
+ j->begin_usec + j->unit->job_timeout, 0,
+ job_dispatch_timer, j);
if (r < 0)
return r;
@@ -1061,7 +1066,12 @@ int job_coldplug(Job *j) {
if (j->timer_event_source)
j->timer_event_source = sd_event_source_unref(j->timer_event_source);
- r = sd_event_add_monotonic(j->manager->event, &j->timer_event_source, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j);
+ r = sd_event_add_time(
+ j->manager->event,
+ &j->timer_event_source,
+ CLOCK_MONOTONIC,
+ j->begin_usec + j->unit->job_timeout, 0,
+ job_dispatch_timer, j);
if (r < 0)
log_debug("Failed to restart timeout for job: %s", strerror(-r));
diff --git a/src/core/manager.c b/src/core/manager.c
index fd22d4863b..360a65a492 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -102,7 +102,12 @@ static int manager_watch_jobs_in_progress(Manager *m) {
return 0;
next = now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC;
- return sd_event_add_monotonic(m->event, &m->jobs_in_progress_event_source, next, 0, manager_dispatch_jobs_in_progress, m);
+ return sd_event_add_time(
+ m->event,
+ &m->jobs_in_progress_event_source,
+ CLOCK_MONOTONIC,
+ next, 0,
+ manager_dispatch_jobs_in_progress, m);
}
#define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED_ON)-1) + sizeof(ANSI_HIGHLIGHT_RED_ON)-1 + 2*(sizeof(ANSI_HIGHLIGHT_OFF)-1))
diff --git a/src/core/mount.c b/src/core/mount.c
index 21b7942946..a979837071 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -163,7 +163,12 @@ static int mount_arm_timer(Mount *m) {
return sd_event_source_set_enabled(m->timer_event_source, SD_EVENT_ONESHOT);
}
- return sd_event_add_monotonic(UNIT(m)->manager->event, &m->timer_event_source, now(CLOCK_MONOTONIC) + m->timeout_usec, 0, mount_dispatch_timer, m);
+ return sd_event_add_time(
+ UNIT(m)->manager->event,
+ &m->timer_event_source,
+ CLOCK_MONOTONIC,
+ now(CLOCK_MONOTONIC) + m->timeout_usec, 0,
+ mount_dispatch_timer, m);
}
static void mount_unwatch_control_pid(Mount *m) {
diff --git a/src/core/scope.c b/src/core/scope.c
index aa4978de4c..e8f9e8dd73 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -83,7 +83,12 @@ static int scope_arm_timer(Scope *s) {
return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT);
}
- return sd_event_add_monotonic(UNIT(s)->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + s->timeout_stop_usec, 0, scope_dispatch_timer, s);
+ return sd_event_add_time(
+ UNIT(s)->manager->event,
+ &s->timer_event_source,
+ CLOCK_MONOTONIC,
+ now(CLOCK_MONOTONIC) + s->timeout_stop_usec, 0,
+ scope_dispatch_timer, s);
}
static void scope_set_state(Scope *s, ScopeState state) {
diff --git a/src/core/service.c b/src/core/service.c
index 78a2e06fff..67467b2d6d 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -257,7 +257,12 @@ static void service_start_watchdog(Service *s) {
r = sd_event_source_set_enabled(s->watchdog_event_source, SD_EVENT_ONESHOT);
} else {
- r = sd_event_add_monotonic(UNIT(s)->manager->event, &s->watchdog_event_source, s->watchdog_timestamp.monotonic + s->watchdog_usec, 0, service_dispatch_watchdog, s);
+ r = sd_event_add_time(
+ UNIT(s)->manager->event,
+ &s->watchdog_event_source,
+ CLOCK_MONOTONIC,
+ s->watchdog_timestamp.monotonic + s->watchdog_usec, 0,
+ service_dispatch_watchdog, s);
if (r < 0) {
log_warning_unit(UNIT(s)->id, "%s failed to add watchdog timer: %s", UNIT(s)->id, strerror(-r));
return;
@@ -345,7 +350,12 @@ static int service_arm_timer(Service *s, usec_t usec) {
return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT);
}
- return sd_event_add_monotonic(UNIT(s)->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + usec, 0, service_dispatch_timer, s);
+ return sd_event_add_time(
+ UNIT(s)->manager->event,
+ &s->timer_event_source,
+ CLOCK_MONOTONIC,
+ now(CLOCK_MONOTONIC) + usec, 0,
+ service_dispatch_timer, s);
}
#ifdef HAVE_SYSV_COMPAT
diff --git a/src/core/socket.c b/src/core/socket.c
index 3708a86f4d..7c18a2b75c 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -168,7 +168,12 @@ static int socket_arm_timer(Socket *s) {
return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT);
}
- return sd_event_add_monotonic(UNIT(s)->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + s->timeout_usec, 0, socket_dispatch_timer, s);
+ return sd_event_add_time(
+ UNIT(s)->manager->event,
+ &s->timer_event_source,
+ CLOCK_MONOTONIC,
+ now(CLOCK_MONOTONIC) + s->timeout_usec, 0,
+ socket_dispatch_timer, s);
}
static int socket_instantiate_service(Socket *s) {
diff --git a/src/core/swap.c b/src/core/swap.c
index 7da742e873..10eed6d25f 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -179,7 +179,12 @@ static int swap_arm_timer(Swap *s) {
return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT);
}
- return sd_event_add_monotonic(UNIT(s)->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + s->timeout_usec, 0, swap_dispatch_timer, s);
+ return sd_event_add_time(
+ UNIT(s)->manager->event,
+ &s->timer_event_source,
+ CLOCK_MONOTONIC,
+ now(CLOCK_MONOTONIC) + s->timeout_usec, 0,
+ swap_dispatch_timer, s);
}
static int swap_add_device_links(Swap *s) {
diff --git a/src/core/timer.c b/src/core/timer.c
index 8ed0291ee6..95416f3e74 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -399,7 +399,12 @@ static void timer_enter_waiting(Timer *t, bool initial) {
r = sd_event_source_set_enabled(t->monotonic_event_source, SD_EVENT_ONESHOT);
} else
- r = sd_event_add_monotonic(UNIT(t)->manager->event, &t->monotonic_event_source, t->next_elapse_monotonic, t->accuracy_usec, timer_dispatch, t);
+ r = sd_event_add_time(
+ UNIT(t)->manager->event,
+ &t->monotonic_event_source,
+ CLOCK_MONOTONIC,
+ t->next_elapse_monotonic, t->accuracy_usec,
+ timer_dispatch, t);
if (r < 0)
goto fail;
@@ -421,7 +426,12 @@ static void timer_enter_waiting(Timer *t, bool initial) {
r = sd_event_source_set_enabled(t->realtime_event_source, SD_EVENT_ONESHOT);
} else
- r = sd_event_add_realtime(UNIT(t)->manager->event, &t->realtime_event_source, t->next_elapse_realtime, t->accuracy_usec, timer_dispatch, t);
+ r = sd_event_add_time(
+ UNIT(t)->manager->event,
+ &t->realtime_event_source,
+ CLOCK_REALTIME,
+ t->next_elapse_realtime, t->accuracy_usec,
+ timer_dispatch, t);
if (r < 0)
goto fail;