diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/grok_j2k_encoder_thread.cc | 2 | ||||
| -rw-r--r-- | src/lib/j2k_encoder.cc | 20 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/grok_j2k_encoder_thread.cc b/src/lib/grok_j2k_encoder_thread.cc index 6975d9221..e6c256f11 100644 --- a/src/lib/grok_j2k_encoder_thread.cc +++ b/src/lib/grok_j2k_encoder_thread.cc @@ -67,6 +67,8 @@ try if (_context->launch(frame, grok.selected) && _context->scheduleCompress(frame)) { frame_guard.cancel(); } + + boost::this_thread::interruption_point(); } } catch (boost::thread_interrupted& e) diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index b416f921d..3aaaa4e76 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -475,13 +475,19 @@ J2KEncoder::retry(DCPVideo video) { #ifdef DCPOMATIC_GROK { - boost::mutex::scoped_lock lock(_threads_mutex); - auto is_grok_thread_with_errors = [](shared_ptr<const J2KEncoderThread> thread) { - auto grok = dynamic_pointer_cast<const GrokJ2KEncoderThread>(thread); - return grok && grok->errors(); - }; - - _give_up = std::any_of(_threads.begin(), _threads.end(), is_grok_thread_with_errors); + /* We might be destroying or remaking these threads, and hopefully in that case we'll come back here + * to check again; we definitely don't want to block in that case waiting to be allowed to check + * _threads. + */ + boost::mutex::scoped_lock lock(_threads_mutex, boost::try_to_lock); + if (lock) { + auto is_grok_thread_with_errors = [](shared_ptr<const J2KEncoderThread> thread) { + auto grok = dynamic_pointer_cast<const GrokJ2KEncoderThread>(thread); + return grok && grok->errors(); + }; + + _give_up = std::any_of(_threads.begin(), _threads.end(), is_grok_thread_with_errors); + } } #endif |
