mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-07-26 08:35:15 -04:00
Use lock on announce stream updates
This commit is contained in:
parent
9ef34fc774
commit
eeb15dcb43
1 changed files with 80 additions and 75 deletions
|
@ -3,6 +3,7 @@ import RNS
|
||||||
import LXMF
|
import LXMF
|
||||||
import time
|
import time
|
||||||
import nomadnet
|
import nomadnet
|
||||||
|
import threading
|
||||||
import RNS.vendor.umsgpack as msgpack
|
import RNS.vendor.umsgpack as msgpack
|
||||||
|
|
||||||
class PNAnnounceHandler:
|
class PNAnnounceHandler:
|
||||||
|
@ -55,6 +56,7 @@ class Directory:
|
||||||
self.directory_entries = {}
|
self.directory_entries = {}
|
||||||
self.announce_stream = []
|
self.announce_stream = []
|
||||||
self.app = app
|
self.app = app
|
||||||
|
self.announce_lock = threading.Lock()
|
||||||
self.load_from_disk()
|
self.load_from_disk()
|
||||||
|
|
||||||
self.pn_announce_handler = PNAnnounceHandler(self)
|
self.pn_announce_handler = PNAnnounceHandler(self)
|
||||||
|
@ -124,6 +126,7 @@ class Directory:
|
||||||
RNS.log("Could not load directory from disk. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("Could not load directory from disk. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
||||||
def lxmf_announce_received(self, source_hash, app_data):
|
def lxmf_announce_received(self, source_hash, app_data):
|
||||||
|
with self.announce_lock:
|
||||||
if app_data != None:
|
if app_data != None:
|
||||||
if self.app.compact_stream:
|
if self.app.compact_stream:
|
||||||
try:
|
try:
|
||||||
|
@ -148,6 +151,7 @@ class Directory:
|
||||||
self.app.ui.main_display.sub_displays.network_display.directory_change_callback()
|
self.app.ui.main_display.sub_displays.network_display.directory_change_callback()
|
||||||
|
|
||||||
def node_announce_received(self, source_hash, app_data, associated_peer):
|
def node_announce_received(self, source_hash, app_data, associated_peer):
|
||||||
|
with self.announce_lock:
|
||||||
if app_data != None:
|
if app_data != None:
|
||||||
if self.app.compact_stream:
|
if self.app.compact_stream:
|
||||||
try:
|
try:
|
||||||
|
@ -177,6 +181,7 @@ class Directory:
|
||||||
self.app.ui.main_display.sub_displays.network_display.directory_change_callback()
|
self.app.ui.main_display.sub_displays.network_display.directory_change_callback()
|
||||||
|
|
||||||
def pn_announce_received(self, source_hash, app_data, associated_peer, associated_node):
|
def pn_announce_received(self, source_hash, app_data, associated_peer, associated_node):
|
||||||
|
with self.announce_lock:
|
||||||
found_node = None
|
found_node = None
|
||||||
for sh in self.directory_entries:
|
for sh in self.directory_entries:
|
||||||
if sh == associated_node:
|
if sh == associated_node:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue