summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-event/sd-event.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-event/sd-event.c')
-rw-r--r--src/libsystemd/sd-event/sd-event.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index bf6f01cfad..d6549148bb 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -131,6 +131,8 @@ struct clock_data {
Prioq *earliest;
Prioq *latest;
usec_t next;
+
+ bool needs_rearm:1;
};
struct sd_event {
@@ -616,6 +618,7 @@ static void source_disconnect(sd_event_source *s) {
prioq_remove(d->earliest, s, &s->time.earliest_index);
prioq_remove(d->latest, s, &s->time.latest_index);
+ d->needs_rearm = true;
break;
}
@@ -715,6 +718,7 @@ static int source_set_pending(sd_event_source *s, bool b) {
prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
prioq_reshuffle(d->latest, s, &s->time.latest_index);
+ d->needs_rearm = true;
}
return 0;
@@ -898,6 +902,8 @@ _public_ int sd_event_add_time(
if (r < 0)
goto fail;
+ d->needs_rearm = true;
+
if (ret)
*ret = s;
@@ -1408,6 +1414,7 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
prioq_reshuffle(d->latest, s, &s->time.latest_index);
+ d->needs_rearm = true;
break;
}
@@ -1471,6 +1478,7 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
prioq_reshuffle(d->latest, s, &s->time.latest_index);
+ d->needs_rearm = true;
break;
}
@@ -1548,6 +1556,7 @@ _public_ int sd_event_source_set_time(sd_event_source *s, uint64_t usec) {
prioq_reshuffle(d->earliest, s, &s->time.earliest_index);
prioq_reshuffle(d->latest, s, &s->time.latest_index);
+ d->needs_rearm = true;
return 0;
}
@@ -1582,6 +1591,7 @@ _public_ int sd_event_source_set_time_accuracy(sd_event_source *s, uint64_t usec
assert(d);
prioq_reshuffle(d->latest, s, &s->time.latest_index);
+ d->needs_rearm = true;
return 0;
}
@@ -1745,6 +1755,11 @@ static int event_arm_timer(
assert(e);
assert(d);
+ if (_likely_(!d->needs_rearm))
+ return 0;
+ else
+ d->needs_rearm = false;
+
a = prioq_peek(d->earliest);
if (!a || a->enabled == SD_EVENT_OFF) {