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) super().__init__(conn)
self.dsp = None self.dsp = None
self.dspLock = threading.Lock()
self.sdr = None self.sdr = None
self.configSubs = [] self.configSubs = []
self.bookmarkSub = None self.bookmarkSub = None
@ -351,6 +352,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
super().close() super().close()
def stopDsp(self): def stopDsp(self):
with self.dspLock:
if self.dsp is not None: if self.dsp is not None:
self.dsp.stop() self.dsp.stop()
self.dsp = None self.dsp = None
@ -358,6 +360,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
self.sdr.removeSpectrumClient(self) self.sdr.removeSpectrumClient(self)
def getDsp(self): def getDsp(self):
with self.dspLock:
if self.dsp is None and self.sdr is not None: if self.dsp is None and self.sdr is not None:
self.dsp = DspManager(self, self.sdr) self.dsp = DspManager(self, self.sdr)
return self.dsp return self.dsp