lock on dsp to avoid race conditions

This commit is contained in:
Jakob Ketterl 2021-04-27 16:58:23 +02:00
parent 0c7b0d2eaa
commit 118335b2b6

View File

@ -140,6 +140,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
super().__init__(conn)
self.dsp = None
self.dspLock = threading.Lock()
self.sdr = None
self.configSubs = []
self.bookmarkSub = None
@ -351,15 +352,17 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
super().close()
def stopDsp(self):
if self.dsp is not None:
self.dsp.stop()
self.dsp = None
with self.dspLock:
if self.dsp is not None:
self.dsp.stop()
self.dsp = None
if self.sdr is not None:
self.sdr.removeSpectrumClient(self)
def getDsp(self):
if self.dsp is None and self.sdr is not None:
self.dsp = DspManager(self, self.sdr)
with self.dspLock:
if self.dsp is None and self.sdr is not None:
self.dsp = DspManager(self, self.sdr)
return self.dsp
def write_spectrum_data(self, data):