diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-11-04 23:33:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-11-04 23:36:56 +0100 |
| commit | 0fc3ee1eac41d391ebb79044b0f46849a90f5138 (patch) | |
| tree | 4dd05b5aff4a6297adfe9cbc91848c789708db31 /src/lib | |
| parent | 4b91800c7de893ec1bbc5a00ab245fd6c01b8b25 (diff) | |
Re-add mutex that was taken away in
73ebb92e9df01ba7afb97121b6e2cef6ca13a18e
I'm not sure why it was removed, and it seems necessary;
servers_list_changed() can be called from a variety of different places
(the constructor and two different EncodeServerFinder threads).
May help with #1854.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/j2k_encoder.cc | 9 | ||||
| -rw-r--r-- | src/lib/j2k_encoder.h | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 18bb27645..c000f8599 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -178,7 +178,11 @@ J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time) { _waker.nudge (); - size_t threads = _threads->size(); + size_t threads = 0; + { + boost::mutex::scoped_lock lm (_threads_mutex); + threads = _threads->size(); + } boost::mutex::scoped_lock queue_lock (_queue_mutex); @@ -240,6 +244,7 @@ void J2KEncoder::terminate_threads () { boost::this_thread::disable_interruption dis; + boost::mutex::scoped_lock lm (_threads_mutex); if (!_threads) { return; @@ -370,6 +375,8 @@ J2KEncoder::servers_list_changed () terminate_threads (); _threads.reset (new boost::thread_group()); + boost::mutex::scoped_lock lm (_threads_mutex); + /* XXX: could re-use threads */ if (!Config::instance()->only_servers_encode ()) { diff --git a/src/lib/j2k_encoder.h b/src/lib/j2k_encoder.h index d56fc1aec..818c75c99 100644 --- a/src/lib/j2k_encoder.h +++ b/src/lib/j2k_encoder.h @@ -87,6 +87,7 @@ private: EventHistory _history; + boost::mutex _threads_mutex; boost::shared_ptr<boost::thread_group> _threads; mutable boost::mutex _queue_mutex; |
