summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2021-06-21 10:14:07 -0500
committerJason Reiss <jreiss@multitech.com>2021-06-21 10:16:13 -0500
commitea0593a22cc71bebfcbce46836940d363c674b7c (patch)
treed37253b43e4cb4bdc3c0e2cf39e20c0eccbb0abf
parent346d752c00b1e5a7d1b0adf0d92cf437a4895679 (diff)
downloadpacket_forwarder_mtac_full-ea0593a22cc71bebfcbce46836940d363c674b7c.tar.gz
packet_forwarder_mtac_full-ea0593a22cc71bebfcbce46836940d363c674b7c.tar.bz2
packet_forwarder_mtac_full-ea0593a22cc71bebfcbce46836940d363c674b7c.zip
Change the auto restart to use process clock time rather than sx1301 counter4.0.11
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.c18
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 f6f126c..d1f74ba 100644
--- a/lora_pkt_fwd/src/lora_pkt_fwd.c
+++ b/lora_pkt_fwd/src/lora_pkt_fwd.c
@@ -1869,6 +1869,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) {
@@ -2007,16 +2011,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;
/* read the currrent temperature */
pthread_mutex_unlock(&mx_concent);