]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: convert bootchart and lldp code to use clock_boottime_or_monotonic() 844/head
authorLennart Poettering <lennart@poettering.net>
Mon, 3 Aug 2015 14:43:29 +0000 (16:43 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 3 Aug 2015 15:40:46 +0000 (17:40 +0200)
We should avoid using CLOCK_BOOTTIME directly unless we actually can
sensible distuingish it from CLOCK_MONOTONIC. CLOCK_BOOTTIME is only
fully feature on very recent Linux kernels, hence we should stick to a
fallback logic, which is already available in the
clock_boottime_or_monotonic() call.

src/bootchart/bootchart.c
src/libsystemd-network/sd-lldp.c
src/network/networkctl.c

index 1625d51fa8098c9b982bb09a790d9cf5d1c5c7ce..322cec84a9efabc04bd9bdc7911424e61e295013 100644 (file)
@@ -367,7 +367,7 @@ int main(int argc, char *argv[]) {
                 struct timespec n;
                 double uptime;
 
-                clock_gettime(CLOCK_BOOTTIME, &n);
+                clock_gettime(clock_boottime_or_monotonic(), &n);
                 uptime = (n.tv_sec + (n.tv_nsec / (double) NSEC_PER_SEC));
 
                 log_start = gettime_ns();
index 034163eb9ec22cdeb20a72169341ec3069f05f9e..574e04b541e48cda0e7d77d2569c7ab7c94f661f 100644 (file)
@@ -392,7 +392,7 @@ static void lldp_mib_delete_objects(sd_lldp *lldp) {
                         break;
 
                 if (t <= 0)
-                        t = now(CLOCK_BOOTTIME);
+                        t = now(clock_boottime_or_monotonic());
 
                 if (p->until > t)
                         break;
@@ -490,7 +490,7 @@ int sd_lldp_save(sd_lldp *lldp, const char *lldp_file) {
                         free(s);
                         s = k;
 
-                        time = now(CLOCK_BOOTTIME);
+                        time = now(clock_boottime_or_monotonic());
 
                         /* Don't write expired packets */
                         if (time - p->until <= 0)
index 9d6c453dbc9411dffdb563a3d38ddf7d62164cad..6c36a4ecface4ccde6b4311f6a5d67192ec1b270 100644 (file)
@@ -976,7 +976,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
                                                 return log_warning_errno(r < 0 ? r : ERANGE,
                                                                          "Failed to parse TTL \"%s\": %m", b);
 
-                                        time = now(CLOCK_BOOTTIME);
+                                        time = now(clock_boottime_or_monotonic());
                                         if (x < time)
                                                 continue;