aboutgitcodebugslistschat
path: root/log.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2024-07-25 17:58:44 +0200
committerStefano Brivio <sbrivio@redhat.com>2024-07-26 13:47:36 +0200
commit77c092ee5ede9a2642978b9874b3c17e88829fbf (patch)
tree3675a63c55718ef6ed0bde5a7635e109370ffbb0 /log.c
parente5c37ba0f419fd6c46d11ee9ec909b3fa9d2aa2f (diff)
downloadpasst-77c092ee5ede9a2642978b9874b3c17e88829fbf.tar
passt-77c092ee5ede9a2642978b9874b3c17e88829fbf.tar.gz
passt-77c092ee5ede9a2642978b9874b3c17e88829fbf.tar.bz2
passt-77c092ee5ede9a2642978b9874b3c17e88829fbf.tar.lz
passt-77c092ee5ede9a2642978b9874b3c17e88829fbf.tar.xz
passt-77c092ee5ede9a2642978b9874b3c17e88829fbf.tar.zst
passt-77c092ee5ede9a2642978b9874b3c17e88829fbf.zip
log: Fetch log times with CLOCK_MONOTONIC, not CLOCK_REALTIME
We report relative timestamps in logs, so we want to avoid jumps in the system time. Suggested-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'log.c')
-rw-r--r--log.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/log.c b/log.c
index 9474bad..0fb25b7 100644
--- a/log.c
+++ b/log.c
@@ -68,7 +68,7 @@ void vlogmsg(bool newline, int pri, const char *format, va_list ap)
struct timespec tp;
if (debug_print) {
- clock_gettime(CLOCK_REALTIME, &tp);
+ clock_gettime(CLOCK_MONOTONIC, &tp);
fprintf(stderr, logtime_fmt_and_arg(&tp));
fprintf(stderr, ": ");
}
@@ -382,7 +382,7 @@ void logfile_write(bool newline, int pri, const char *format, va_list ap)
char buf[BUFSIZ];
int n;
- if (clock_gettime(CLOCK_REALTIME, &now))
+ if (clock_gettime(CLOCK_MONOTONIC, &now))
return;
n = snprintf(buf, BUFSIZ, logtime_fmt_and_arg(&now));