From ac5b6fa6083d7a9cc73b10bc4b2ae77221ad9ff2 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Tue, 15 Oct 2024 00:11:51 +0300 Subject: [PATCH] Prevent stuck vectors in objects._pending --- minode/connection.py | 1 + minode/manager.py | 2 ++ minode/sql.py | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/minode/connection.py b/minode/connection.py index 3dd5f9a..4750181 100644 --- a/minode/connection.py +++ b/minode/connection.py @@ -485,6 +485,7 @@ class Connection(ConnectionBase): logging.debug(dest) shared.i2p_unchecked_node_pool.add((dest, 'i2p')) shared.vector_advertise_queue.put(obj.vector) + shared.objects.check(obj.vector) def _process_msg_getdata(self, m): getdata = message.GetData.from_message(m) diff --git a/minode/manager.py b/minode/manager.py index b8caae5..f9ebf31 100644 --- a/minode/manager.py +++ b/minode/manager.py @@ -56,6 +56,8 @@ class Manager(threading.Thread): outgoing_connections = 0 for c in shared.connections.copy(): if not c.is_alive() or c.status == 'disconnected': + shared.objects.check( + *(c.vectors_to_get | c.vectors_requested.keys())) with shared.connections_lock: shared.connections.remove(c) else: diff --git a/minode/sql.py b/minode/sql.py index 3a370a7..1de2b55 100644 --- a/minode/sql.py +++ b/minode/sql.py @@ -56,6 +56,11 @@ class Inventory(): expires, obj_type, version, stream, data, offset, tag=tag, vector=vector) + def check(self, *vectors): + with self._lock: + for vector in vectors: + self._pending.discard(vector) + def cleanup(self): if len(self._pending) > 100: logging.warning( @@ -230,7 +235,6 @@ class Inventory(): return with self._lock: self._last[vector] = obj - self._pending.discard(vector) def __bool__(self): if self._last: