From aadcfc9ea6dce6ba800568067a45b879c8c5039e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 26 Apr 2023 15:28:09 +0200 Subject: [PATCH] BUG/MINOR: clock: fix a few occurrences of 'now' being used in place of 'date' Since commit 28360dc ("MEDIUM: clock: force internal time to wrap early after boot") we have a much clearer distinction between 'now' (the internal, drifting clock) and 'date' (the wall clock time). There were still a few places where 'now' was being used for human consumption. No backport is needed. --- addons/deviceatlas/dadwsch.c | 6 +++--- src/calltrace.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/deviceatlas/dadwsch.c b/addons/deviceatlas/dadwsch.c index e35566a3f..e0173cf5a 100644 --- a/addons/deviceatlas/dadwsch.c +++ b/addons/deviceatlas/dadwsch.c @@ -44,7 +44,7 @@ static void dadwlog(dw_config_t cfg, const char* msg) { time_t now = time(NULL); char buf[26] = {0}; - ctime_r(&now, buf); + ctime_r(&date, buf); buf[24] = 0; fprintf(stderr, "%s: %s\n", buf, msg); } @@ -63,7 +63,7 @@ static dw_status_t dadwnot(void *a, dw_config_t *cfg) jsond = da_getdatacreation(&o->atlas); dwgetfinalp(o->dcfg.info, atlasp, sizeof(atlasp)); ctime_r(&jsond, jsondbuf); - ctime_r(&now, buf); + ctime_r(&date, buf); jsondbuf[24] = 0; buf[24] = 0; @@ -150,7 +150,7 @@ int main(int argc, char **argv) if (!dset) { time_t now = time(NULL); - struct tm *cnow = gmtime(&now); + struct tm *cnow = gmtime(&date); memcpy(&global_deviceatlassch.o.dcfg.info.rtm, cnow, offsetof(struct tm, tm_mday)); } diff --git a/src/calltrace.c b/src/calltrace.c index f72e12116..3946b286e 100644 --- a/src/calltrace.c +++ b/src/calltrace.c @@ -76,7 +76,7 @@ static int open_trace() if (!log) log = stderr; - now_ptr = &now; + now_ptr = &date; if (getenv("HAPROXY_TRACE_FAST") != NULL) { fast_time = 1; now_ptr = &trace_now;