Fix #28: log messages stuck in 1969
The timer_now() API, introduced in 2019, returns time relative to boot. Useful for relative time comparisons, but when used for absolute time, e.g. for log messages, it must be offset with boot_time. This patch fixes issue #28, but also wall messages, which exhibits the same problem. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
parent
4ab8bc7b40
commit
eb454d7d37
@ -978,7 +978,7 @@ parsemsg_rfc3164(const char *from, int pri, char *msg)
|
|||||||
* This loop can only run for at most three
|
* This loop can only run for at most three
|
||||||
* iterations before terminating.
|
* iterations before terminating.
|
||||||
*/
|
*/
|
||||||
t_now = timer_now();
|
t_now = boot_time + timer_now();
|
||||||
localtime_r(&t_now, &tm_now);
|
localtime_r(&t_now, &tm_now);
|
||||||
for (year = tm_now.tm_year + 1;; --year) {
|
for (year = tm_now.tm_year + 1;; --year) {
|
||||||
assert(year >= tm_now.tm_year - 1);
|
assert(year >= tm_now.tm_year - 1);
|
||||||
@ -1765,7 +1765,7 @@ void wallmsg(struct filed *f, struct iovec *iov, int iovcnt)
|
|||||||
* and doing notty().
|
* and doing notty().
|
||||||
*/
|
*/
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
time_t t_now = timer_now();
|
time_t t_now = boot_time + timer_now();
|
||||||
|
|
||||||
(void)signal(SIGTERM, SIG_DFL);
|
(void)signal(SIGTERM, SIG_DFL);
|
||||||
(void)alarm(0);
|
(void)alarm(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user