From 562ae52c1effcca092ba5cc9451b29cd01c1947d Mon Sep 17 00:00:00 2001 From: Hemna Date: Thu, 15 Jul 2021 14:11:30 -0400 Subject: [PATCH] Fixed the Ack thread not resending acks This patch fixes a bug in the AckThread. The thread loop was exiting after the first attempt to send the ack. Thread loops have to return True, in order to be called again as this is the mechanism in which aprsd gracefully shuts down all threads. --- aprsd/messaging.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/aprsd/messaging.py b/aprsd/messaging.py index d340fc7..a539094 100644 --- a/aprsd/messaging.py +++ b/aprsd/messaging.py @@ -9,7 +9,7 @@ import re import threading import time -from aprsd import client, stats, threads, utils +from aprsd import client, stats, threads, trace, utils LOG = logging.getLogger("APRSD") @@ -461,25 +461,6 @@ class AckMessage(Message): self.id, ) - def send_thread(self): - """Separate thread to send acks with retries.""" - cl = client.get_client() - for i in range(self.retry_count, 0, -1): - log_message( - "Sending ack", - str(self).rstrip("\n"), - None, - ack=self.id, - tocall=self.tocall, - retry_number=i, - ) - cl.sendall(str(self)) - stats.APRSDStats().ack_tx_inc() - # aprs duplicate detection is 30 secs? - # (21 only sends first, 28 skips middle) - time.sleep(31) - # end_send_ack_thread - def send(self): LOG.debug("Send ACK({}:{}) to radio.".format(self.tocall, self.id)) thread = SendAckThread(self) @@ -506,8 +487,10 @@ class SendAckThread(threads.APRSDThread): self.ack = ack super().__init__("SendAck-{}".format(self.ack.id)) + @trace.trace def loop(self): """Separate thread to send acks with retries.""" + LOG.debug("SendAckThread loop start") send_now = False if self.ack.last_send_attempt == self.ack.retry_count: # we reached the send limit, don't send again @@ -546,6 +529,7 @@ class SendAckThread(threads.APRSDThread): self.ack.last_send_attempt += 1 self.ack.last_send_time = datetime.datetime.now() time.sleep(5) + return True def log_packet(packet):