diff options
-rw-r--r-- | lora_pkt_fwd/src/lora_pkt_fwd.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index bfcca1f..fbab482 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -1873,6 +1873,10 @@ int main(int argc, char** argv) sigaction(SIGHUP, &sighupact, NULL); /* rotate logfile on HUP */ signal(SIGPIPE, SIG_IGN); /* ignore writes after closing socket */ + struct timespec start_time; + struct timespec check_time; + + clock_gettime(CLOCK_MONOTONIC, &start_time); /* main loop task : statistics collection */ while (!exit_sig && !quit_sig) { @@ -2011,16 +2015,12 @@ int main(int argc, char** argv) break; } - static uint32_t last_tstamp = 0; - static uint32_t rollover_cnt = 0; - if (trig_tstamp < last_tstamp) { - if (rollover_cnt++ > 10) { - exit_sig = true; - MSG("INFO: periodic restart, process is exiting.\n"); - break; - } + clock_gettime(CLOCK_MONOTONIC, &check_time); + + if ((int)(difftimespec(recv_time, send_time)) > (10 * 60 * 60)) { // allow forwarder to run a maximum of 10 hours before forcing a restart + MSG("INFO: periodic restart, process is exiting.\n"); + exit(1); } - last_tstamp = trig_tstamp; pthread_mutex_unlock(&mx_concent); if (i != LGW_HAL_SUCCESS) { |