summaryrefslogtreecommitdiff
path: root/src/polaris/protocol.py
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-07-02 15:41:06 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-07-02 15:41:06 +0300
commit9b280e35186a3f0078a39ca013454cc8d0c21d62 (patch)
tree654ab07205f75b89afb2b9af450c3615f9798527 /src/polaris/protocol.py
parent28560dbba91d077d871fed12d25576099c413555 (diff)
polaris/protocol: ping improvements
Diffstat (limited to 'src/polaris/protocol.py')
-rw-r--r--src/polaris/protocol.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/polaris/protocol.py b/src/polaris/protocol.py
index a86ed84..d562ff9 100644
--- a/src/polaris/protocol.py
+++ b/src/polaris/protocol.py
@@ -1011,13 +1011,15 @@ class UDPConnection(threading.Thread, ConnectionStatusListener):
self._logger.error(f'{lpfx} rm path: removing from outgoing_queue raised an exception: {str(exc)}')
# ping pong
- if self.outgoing_time_1st != 0 and self.status == ConnectionStatus.CONNECTED:
+ if not message and self.outgoing_time_1st != 0 and self.status == ConnectionStatus.CONNECTED:
now = time.time()
out_delta = now - self.outgoing_time
in_delta = now - self.incoming_time
- if not message and max(out_delta, in_delta) > PING_FREQUENCY:
+ if max(out_delta, in_delta) > PING_FREQUENCY:
self._logger.debug(f'{lpfx} no activity: in for {in_delta:.2f}s, out for {out_delta:.2f}s, time to ping the damn thing')
message = WrappedMessage(PingMessage(), ack=True)
+ # add it to outgoing_queue in order to be aggressively resent in future (if needed)
+ self.outgoing_queue.insert(0, message)
return message