1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-08-03 05:52:26 -04:00

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.
This commit is contained in:
Hemna 2021-07-15 14:11:30 -04:00
parent 3c45d8bd0f
commit 562ae52c1e

View File

@ -9,7 +9,7 @@ import re
import threading import threading
import time import time
from aprsd import client, stats, threads, utils from aprsd import client, stats, threads, trace, utils
LOG = logging.getLogger("APRSD") LOG = logging.getLogger("APRSD")
@ -461,25 +461,6 @@ class AckMessage(Message):
self.id, 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): def send(self):
LOG.debug("Send ACK({}:{}) to radio.".format(self.tocall, self.id)) LOG.debug("Send ACK({}:{}) to radio.".format(self.tocall, self.id))
thread = SendAckThread(self) thread = SendAckThread(self)
@ -506,8 +487,10 @@ class SendAckThread(threads.APRSDThread):
self.ack = ack self.ack = ack
super().__init__("SendAck-{}".format(self.ack.id)) super().__init__("SendAck-{}".format(self.ack.id))
@trace.trace
def loop(self): def loop(self):
"""Separate thread to send acks with retries.""" """Separate thread to send acks with retries."""
LOG.debug("SendAckThread loop start")
send_now = False send_now = False
if self.ack.last_send_attempt == self.ack.retry_count: if self.ack.last_send_attempt == self.ack.retry_count:
# we reached the send limit, don't send again # 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_attempt += 1
self.ack.last_send_time = datetime.datetime.now() self.ack.last_send_time = datetime.datetime.now()
time.sleep(5) time.sleep(5)
return True
def log_packet(packet): def log_packet(packet):