From a674e8419e16c710e0fb9a9e5d22d069711a9207 Mon Sep 17 00:00:00 2001 From: Bruno Randolf Date: Wed, 12 Jul 2017 10:05:37 +0100 Subject: [PATCH] Add real time and use for display and file --- display.c | 6 +++--- main.c | 5 ++++- main.h | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/display.c b/display.c index 9597ff8..777c7a2 100644 --- a/display.c +++ b/display.c @@ -238,7 +238,7 @@ static void update_menu(void) wattroff(stdscr, BLACKONWHITE); update_mini_status(); - update_clock(&time_mono.tv_sec); + update_clock(&time_real.tv_sec); } /******************* WINDOW MANAGEMENT / UPDATE *******************/ @@ -306,7 +306,7 @@ void update_display_clock(void) { /* helper to update just the clock every second */ if (time_mono.tv_sec > time_mono.tv_sec) { - update_clock(&time_mono.tv_sec); + update_clock(&time_real.tv_sec); doupdate(); } } @@ -339,7 +339,7 @@ void update_display(struct packet_info* pkt) /* update clock every second */ if (time_mono.tv_sec > time_mono.tv_sec) - update_clock(&time_mono.tv_sec); + update_clock(&time_real.tv_sec); last_time = time_mono; diff --git a/main.c b/main.c index 5c70eec..d1ef98e 100644 --- a/main.c +++ b/main.c @@ -58,6 +58,7 @@ struct node_names_info node_names; struct config conf; struct timespec time_mono; +struct timespec time_real; int mon; /* monitoring socket */ @@ -214,7 +215,7 @@ static void write_to_file(struct packet_info* p) { char buf[40]; int i; - struct tm* ltm = localtime(&time_mono.tv_sec); + struct tm* ltm = localtime(&time_real.tv_sec); //timestamp, e.g. 2015-05-16 15:05:44.338806 +0300 i = strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", ltm); @@ -725,6 +726,8 @@ int main(int argc, char** argv) exit(1); clock_gettime(CLOCK_MONOTONIC, &time_mono); + clock_gettime(CLOCK_REALTIME, &time_real); + node_timeout(); if (conf.serveraddr[0] == '\0') { /* server */ diff --git a/main.h b/main.h index c234217..99c9722 100644 --- a/main.h +++ b/main.h @@ -345,6 +345,7 @@ struct config { extern struct config conf; extern struct timespec time_mono; +extern struct timespec time_real; void free_lists(void); void init_spectrum(void);