dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
b677e7
From 5b5a590c5a8bbaebbecf4ab4797334a09a870287 Mon Sep 17 00:00:00 2001
b677e7
From: Lennart Poettering <lennart@poettering.net>
b677e7
Date: Mon, 23 Nov 2020 15:33:50 +0100
b677e7
Subject: [PATCH] sd-event: let's suffix last_run/last_log with "_usec"
b677e7
b677e7
Otherwise it's a bit confusing what this is about: two timestamps.
b677e7
b677e7
(cherry picked from commit e6a7bee538f6638c2d5ca2afc66bf47cba3f075c)
b677e7
b677e7
Related: #1819868
b677e7
---
b677e7
 src/libsystemd/sd-event/sd-event.c | 12 ++++++------
b677e7
 1 file changed, 6 insertions(+), 6 deletions(-)
b677e7
b677e7
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
b677e7
index 9d42157206..88641879cc 100644
b677e7
--- a/src/libsystemd/sd-event/sd-event.c
b677e7
+++ b/src/libsystemd/sd-event/sd-event.c
b677e7
@@ -301,7 +301,7 @@ struct sd_event {
b677e7
 
b677e7
         LIST_HEAD(sd_event_source, sources);
b677e7
 
b677e7
-        usec_t last_run, last_log;
b677e7
+        usec_t last_run_usec, last_log_usec;
b677e7
         unsigned delays[sizeof(usec_t) * 8];
b677e7
 };
b677e7
 
b677e7
@@ -3579,19 +3579,19 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
b677e7
         assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
b677e7
         assert_return(e->state == SD_EVENT_INITIAL, -EBUSY);
b677e7
 
b677e7
-        if (e->profile_delays && e->last_run) {
b677e7
+        if (e->profile_delays && e->last_run_usec != 0) {
b677e7
                 usec_t this_run;
b677e7
                 unsigned l;
b677e7
 
b677e7
                 this_run = now(CLOCK_MONOTONIC);
b677e7
 
b677e7
-                l = u64log2(this_run - e->last_run);
b677e7
+                l = u64log2(this_run - e->last_run_usec);
b677e7
                 assert(l < ELEMENTSOF(e->delays));
b677e7
                 e->delays[l]++;
b677e7
 
b677e7
-                if (this_run - e->last_log >= 5*USEC_PER_SEC) {
b677e7
+                if (this_run - e->last_log_usec >= 5*USEC_PER_SEC) {
b677e7
                         event_log_delays(e);
b677e7
-                        e->last_log = this_run;
b677e7
+                        e->last_log_usec = this_run;
b677e7
                 }
b677e7
         }
b677e7
 
b677e7
@@ -3601,7 +3601,7 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
b677e7
                 r = sd_event_wait(e, timeout);
b677e7
 
b677e7
         if (e->profile_delays)
b677e7
-                e->last_run = now(CLOCK_MONOTONIC);
b677e7
+                e->last_run_usec = now(CLOCK_MONOTONIC);
b677e7
 
b677e7
         if (r > 0) {
b677e7
                 /* There's something now, then let's dispatch it */