summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-20 10:21:13 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-20 10:21:13 +0100
commitb34310b4e90af1442363fe09db082d68e1721130 (patch)
tree5d0dc102a52bd02db6bbb1f2ff8e4a046a2d3b39 /src
parentc7354c8f2052d63b3d4e00da6b57956150c25dbe (diff)
Try to fix intermittent deadlocks with encoding servers.
Before this commit all encoding threads could be removed and then ::encode would always wait on _full_condition no matter what the queue size.
Diffstat (limited to 'src')
-rw-r--r--src/lib/encoder.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index cc2deaa93..652412ddf 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -207,11 +207,13 @@ Encoder::encode (shared_ptr<PlayerVideo> pv)
boost::mutex::scoped_lock queue_lock (_queue_mutex);
- /* Wait until the queue has gone down a bit */
- while (_queue.size() >= threads * 2) {
- LOG_TIMING ("decoder-sleep queue=%1", _queue.size());
+ /* Wait until the queue has gone down a bit. Allow one thing in the queue even
+ when there are no threads.
+ */
+ while (_queue.size() >= (threads * 2) + 1) {
+ LOG_TIMING ("decoder-sleep queue=%1 threads=%2", _queue.size(), threads);
_full_condition.wait (queue_lock);
- LOG_TIMING ("decoder-wake queue=%1", _queue.size());
+ LOG_TIMING ("decoder-wake queue=%1 threads=%2", _queue.size(), threads);
}
_writer->rethrow ();