From 7bc691169ab299c5f2e090eb00d5ce759517278d Mon Sep 17 00:00:00 2001 From: Jeremy O'Brien <956a74d715fe9cb2e9da0a19b067b414> Date: Thu, 28 May 2026 11:50:01 -0400 Subject: [PATCH] Conversation: avoid calling conversation_list() on every received announce; this can cause fd starvation during an announce storm --- nomadnet/Conversation.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nomadnet/Conversation.py b/nomadnet/Conversation.py index 2802f9a..c543d9c 100644 --- a/nomadnet/Conversation.py +++ b/nomadnet/Conversation.py @@ -24,15 +24,13 @@ class Conversation: if not destination_hash in app.ignored_list: destination_hash_text = RNS.hexrep(destination_hash, delimit=False) - # Check if the announced destination is in - # our list of conversations - if destination_hash_text in [e[0] for e in Conversation.conversation_list(app)]: - if app.directory.find(destination_hash): - if Conversation.created_callback != None: - Conversation.created_callback() - else: - if Conversation.created_callback != None: - Conversation.created_callback() + # Notify if the announced destination is one of our + # existing conversations. Checking the directory directly + # avoids scanning and opening every conversation on disk + # for each announce received. + if os.path.isdir(app.conversationpath + "/" + destination_hash_text): + if Conversation.created_callback != None: + Conversation.created_callback() # This reformats the new v0.5.0 announce data back to the expected format # for nomadnets storage and other handling functions.