summaryrefslogtreecommitdiffstats
path: root/recording
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2023-03-22 00:54:34 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2023-03-22 00:59:56 +0100
commit08aefab4a83a27678cbaeabc630f09a21c1aaec1 (patch)
tree1ded3db519696974e38c25777e0dee5b008dc9d3 /recording
parent6f924dc1df1b7e47876faf8911bded24433532a1 (diff)
Abort starting the helpers when the recording is stopped
The recording is stopped in a different thread than it is started. Stopping the recording stops the helpers, like the display, but if they are stopped at the same time that they are being started there could be a race condition in which the helper is tried to be stopped in one thread and, immediately after that, the helper is started in the other thread. This is now handled by explicitly checking if the recording was stopped after starting each helper and aborting the start if it was. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'recording')
-rw-r--r--recording/src/nextcloud/talk/recording/Service.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/recording/src/nextcloud/talk/recording/Service.py b/recording/src/nextcloud/talk/recording/Service.py
index 802cc6b59..8489c9044 100644
--- a/recording/src/nextcloud/talk/recording/Service.py
+++ b/recording/src/nextcloud/talk/recording/Service.py
@@ -216,10 +216,16 @@ class Service:
self._display = Display(size=(width, height), manage_global_env=False)
self._display.start()
+ if self._stopped.is_set():
+ raise Exception("Display started after recording was stopped")
+
# Start new audio sink for the audio output of the browser.
self._audioModuleIndex, audioSinkIndex = newAudioSink(sanitizedBackend, self.token)
audioSinkIndex = str(audioSinkIndex)
+ if self._stopped.is_set():
+ raise Exception("Audio sink started after recording was stopped")
+
env = self._display.env()
env['PULSE_SINK'] = audioSinkIndex
@@ -229,6 +235,12 @@ class Service:
self._logger.debug("Joining call")
self._participant.joinCall(self.token)
+ if self._stopped.is_set():
+ # Not strictly needed, as if the participant is started or the
+ # call is joined after the recording was stopped there will be
+ # no display and it will automatically fail, but just in case.
+ raise Exception("Call joined after recording was stopped")
+
self._started.set()
BackendNotifier.started(self.backend, self.token, self.status, actorType, actorId)
@@ -245,6 +257,12 @@ class Service:
# Log recorder output.
Thread(target=recorderLog, args=[self.backend, self.token, self._process.stdout], daemon=True).start()
+ if self._stopped.is_set():
+ # Not strictly needed, as if the recorder is started after the
+ # recording was stopped there will be no display and it will
+ # automatically fail, but just in case.
+ raise Exception("Call joined after recording was stopped")
+
returnCode = self._process.wait()
# recorder process will be explicitly terminated when needed, which