summaryrefslogtreecommitdiff
path: root/src/lib/player.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-01-28 23:23:47 +0100
committerCarl Hetherington <cth@carlh.net>2020-01-28 23:23:47 +0100
commitdf48c75c38dd788835a93540aea243a2dac4bb10 (patch)
treeddb89cf5bada00cfe4e77301c71123297bd24946 /src/lib/player.h
parent95f4d8740de74cdecf6658ab2607c0af9732904e (diff)
Fix deadlock during content examination.
Before this fix, the following situation could happen in threads A and B: A: Some DONE signal happens; this triggers setup_pieces which takes a lock on the player mutex. B: FFmpegContent::examine takes a lock on the content mutex. B: FFmpegContent::examine adds a stream B: That causes STREAMS PENDING to be emitted. B: This tries to take a lock on the player mutex so it can update _suspended A: setup_pieces tries to access some content information, hence tries to take a lock on the content mutex. Now B is holding the CL and awaiting the PL and A is holding the PL and awaiting the CL. It feels like the root cause of this is that while setup_pieces is happening another change (which would itself cause setup_pieces) is announced, and this isn't dealt with properly. There are two steps here; _suspended is protected with an atomic rather than using _mutex, and also it can cope with being updated recursively.
Diffstat (limited to 'src/lib/player.h')
-rw-r--r--src/lib/player.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/player.h b/src/lib/player.h
index 2fd7c8668..68531cfb3 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -149,8 +149,8 @@ private:
boost::shared_ptr<const Film> _film;
boost::shared_ptr<const Playlist> _playlist;
- /** true if we are suspended (i.e. pass() and seek() do nothing) */
- bool _suspended;
+ /** > 0 if we are suspended (i.e. pass() and seek() do nothing) */
+ boost::atomic<int> _suspended;
std::list<boost::shared_ptr<Piece> > _pieces;
/** Size of the image in the DCP (e.g. 1990x1080 for flat) */