mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-04-27 22:25:37 +00:00
Improved gracious transport data persist handling
This commit is contained in:
parent
8093c3cd2c
commit
e0aa46ba22
2 changed files with 12 additions and 5 deletions
|
|
@ -328,7 +328,8 @@ class LocalClientInterface(Interface):
|
|||
if hasattr(self, "parent_interface") and self.parent_interface != None:
|
||||
self.parent_interface.clients -= 1
|
||||
if hasattr(RNS.Transport, "owner") and RNS.Transport.owner != None:
|
||||
RNS.Transport.owner._should_persist_data()
|
||||
background = not self.detached
|
||||
RNS.Transport.owner._should_persist_data(background=background)
|
||||
|
||||
if nowarning == False:
|
||||
RNS.log("The interface "+str(self)+" experienced an unrecoverable error and is being torn down. Restart Reticulum to attempt to open this interface again.", RNS.LOG_ERROR)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ else:
|
|||
from RNS.Interfaces import *
|
||||
|
||||
from RNS.vendor.configobj import ConfigObj
|
||||
from threading import Lock
|
||||
import configparser
|
||||
import multiprocessing.connection
|
||||
import importlib.util
|
||||
|
|
@ -171,6 +172,8 @@ class Reticulum:
|
|||
cachepath = ""
|
||||
interfacepath = ""
|
||||
|
||||
gracious_persist_lock = Lock()
|
||||
|
||||
__instance = None
|
||||
|
||||
__interface_detach_ran = False
|
||||
|
|
@ -995,12 +998,15 @@ class Reticulum:
|
|||
|
||||
def _should_persist_data(self, background=False):
|
||||
if time.time() > self.last_data_persist+Reticulum.GRACIOUS_PERSIST_INTERVAL:
|
||||
self.__persist_data(background=background)
|
||||
def job(): self.__persist_data(background=background)
|
||||
threading.Thread(target=job, daemon=True).start()
|
||||
|
||||
def __persist_data(self, background=False):
|
||||
RNS.Transport.persist_data(background=background)
|
||||
RNS.Identity.persist_data(background=background)
|
||||
self.last_data_persist = time.time()
|
||||
if Reticulum.gracious_persist_lock.locked(): return
|
||||
with Reticulum.gracious_persist_lock:
|
||||
RNS.Transport.persist_data(background=background)
|
||||
RNS.Identity.persist_data(background=background)
|
||||
self.last_data_persist = time.time()
|
||||
|
||||
def __clean_caches(self, background=False):
|
||||
RNS.log("Cleaning resource and packet caches...", RNS.LOG_EXTREME)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue