valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0352-sd-event-expose-the-event-loop-iteration-counter-via.patch

1abbee
From 8fe5d9138039aafd314340b12d6d586d657d53a7 Mon Sep 17 00:00:00 2001
fa0155
From: Lennart Poettering <lennart@poettering.net>
fa0155
Date: Wed, 29 Jun 2016 19:03:26 -0700
fa0155
Subject: [PATCH] sd-event: expose the event loop iteration counter via
fa0155
 sd_event_get_iteration()
fa0155
fa0155
This extends the existing event loop iteration counter to 64bit, and exposes it
fa0155
via a new function sd_event_get_iteration(). This is helpful for cases like
fa0155
issue #3612. After all, since we maintain the counter anyway, we might as well
fa0155
expose it.
fa0155
fa0155
(This also fixes an unrelated issue in the man page for sd_event_wait() where
fa0155
micro and milliseconds got mixed up)
fa0155
fa0155
Cherry-picked from: 7486322b99da5b4d2d00d35b310b035f936f7964
fa0155
Related: #1342173
fa0155
---
fa0155
 src/libsystemd/sd-event/sd-event.c | 14 +++++++++++---
fa0155
 src/systemd/sd-event.h             |  1 +
fa0155
 2 files changed, 12 insertions(+), 3 deletions(-)
fa0155
fa0155
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
181b3f
index 1f1e6fe91..9d48e5a49 100644
fa0155
--- a/src/libsystemd/sd-event/sd-event.c
fa0155
+++ b/src/libsystemd/sd-event/sd-event.c
fa0155
@@ -76,8 +76,8 @@ struct sd_event_source {
fa0155
         int64_t priority;
fa0155
         unsigned pending_index;
fa0155
         unsigned prepare_index;
fa0155
-        unsigned pending_iteration;
fa0155
-        unsigned prepare_iteration;
fa0155
+        uint64_t pending_iteration;
fa0155
+        uint64_t prepare_iteration;
fa0155
 
fa0155
         LIST_FIELDS(sd_event_source, sources);
fa0155
 
fa0155
@@ -169,7 +169,7 @@ struct sd_event {
fa0155
 
fa0155
         pid_t original_pid;
fa0155
 
fa0155
-        unsigned iteration;
fa0155
+        uint64_t iteration;
fa0155
         dual_timestamp timestamp;
fa0155
         usec_t timestamp_boottime;
fa0155
         int state;
fa0155
@@ -2689,3 +2689,11 @@ _public_ int sd_event_get_watchdog(sd_event *e) {
fa0155
 
fa0155
         return e->watchdog;
fa0155
 }
fa0155
+
fa0155
+_public_ int sd_event_get_iteration(sd_event *e, uint64_t *ret) {
fa0155
+        assert_return(e, -EINVAL);
fa0155
+        assert_return(!event_pid_changed(e), -ECHILD);
fa0155
+
fa0155
+        *ret = e->iteration;
fa0155
+        return 0;
fa0155
+}
fa0155
diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h
181b3f
index 25a10f99a..4957f3a32 100644
fa0155
--- a/src/systemd/sd-event.h
fa0155
+++ b/src/systemd/sd-event.h
fa0155
@@ -101,6 +101,7 @@ int sd_event_get_tid(sd_event *e, pid_t *tid);
fa0155
 int sd_event_get_exit_code(sd_event *e, int *code);
fa0155
 int sd_event_set_watchdog(sd_event *e, int b);
fa0155
 int sd_event_get_watchdog(sd_event *e);
fa0155
+int sd_event_get_iteration(sd_event *e, uint64_t *ret);
fa0155
 
fa0155
 sd_event_source* sd_event_source_ref(sd_event_source *s);
fa0155
 sd_event_source* sd_event_source_unref(sd_event_source *s);