summaryrefslogtreecommitdiff
path: root/src/lib/encoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-10-02 10:06:48 +0100
committerCarl Hetherington <cth@carlh.net>2015-10-02 10:06:48 +0100
commitaac97a7653003ab7032d927eeb236cff4ad726d1 (patch)
treea0e0cdf8da922868ad032c94e00eb0839c034638 /src/lib/encoder.cc
parenteafc31e4f513a8ec11bd806e5bf36f21d32689a0 (diff)
Speculative fix for hangs during Encoder::end().
I think it's possible that, if an exception is thrown by an Encoder thread during the clear-out loop at the top of Encoder::end, that loop will hang waiting for a notify() on _full_condition that never comes. Fix this by rethrow()ing in this loop and notifying _full_condition if an encoder thread throws an exception.
Diffstat (limited to 'src/lib/encoder.cc')
-rw-r--r--src/lib/encoder.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index 6fe745dd7..ef58ca09e 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -43,6 +43,7 @@
#include "i18n.h"
#define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL);
+#define LOG_GENERAL_NC(...) _film->log()->log (__VA_ARGS__, Log::TYPE_GENERAL);
#define LOG_ERROR(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_ERROR);
#define LOG_TIMING(...) _film->log()->microsecond_log (String::compose (__VA_ARGS__), Log::TYPE_TIMING);
@@ -95,12 +96,15 @@ Encoder::end ()
/* Keep waking workers until the queue is empty */
while (!_queue.empty ()) {
+ rethrow ();
_empty_condition.notify_all ();
_full_condition.wait (lock);
}
lock.unlock ();
+ LOG_GENERAL_NC (N_("Terminating encoder threads"));
+
terminate_threads ();
LOG_GENERAL (N_("Mopping up %1"), _queue.size());
@@ -373,6 +377,8 @@ try
catch (...)
{
store_current ();
+ /* Wake anything waiting on _full_condition so it can see the exception */
+ _full_condition.notify_all ();
}
void