diff options
author | Jason Reiss <jreiss@multitech.com> | 2021-06-21 10:14:07 -0500 |
---|---|---|
committer | Jason Reiss <jreiss@multitech.com> | 2021-06-21 10:14:07 -0500 |
commit | 216bfce30f9dbbda537b3f572875fb0d67dbd8d7 (patch) | |
tree | a52febbb8ccf9bf0aed5570a6b1805a035fcfe5c | |
parent | 91b82d23fb1506d9176c06049aac4c04312c1cc9 (diff) | |
download | packet_forwarder_mtac_full-216bfce30f9dbbda537b3f572875fb0d67dbd8d7.tar.gz packet_forwarder_mtac_full-216bfce30f9dbbda537b3f572875fb0d67dbd8d7.tar.bz2 packet_forwarder_mtac_full-216bfce30f9dbbda537b3f572875fb0d67dbd8d7.zip |
Change the auto restart to use process clock time rather than sx1301 counter4.0.4-6
Use exit instead of a clean shutdown, race condition between threads may have been causing the process to hang
-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) { |