summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-06-09 22:22:21 +0100
committerCarl Hetherington <cth@carlh.net>2018-06-09 22:22:21 +0100
commit43254ee65acd9100573cff5a6faef3d3ec3e46b1 (patch)
tree474de9e3f86c29c285eff4f1e1328c5ca3fc9c0d /src
parent939d42c25b7b2738dd3cd6c2e8a605489339595e (diff)
Another writer deadlock fix.
Diffstat (limited to 'src')
-rw-r--r--src/lib/writer.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 8ee629309..96fb9e179 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -173,8 +173,10 @@ Writer::repeat (Frame frame, Eyes eyes)
{
boost::mutex::scoped_lock lock (_state_mutex);
- while (_queue.size() > _maximum_queue_size) {
- /* The queue is too big; wait until that is sorted out */
+ while (_queue.size() > _maximum_queue_size && have_sequenced_image_at_queue_head()) {
+ /* The queue is too big, and the main writer thread can run and fix it, so
+ wait until it has done.
+ */
_full_condition.wait (lock);
}
@@ -201,12 +203,9 @@ Writer::fake_write (Frame frame, Eyes eyes)
{
boost::mutex::scoped_lock lock (_state_mutex);
- while (_queue.size() > _maximum_queue_size) {
- /* The queue is too big; wait until that is sorted out. We're assuming here
- that it will be sorted out either by time or by a necessary full-written
- frame being given to us. fake_write() must be called more-or-less in
- order or this will deadlock due to the main write thread waiting for
- a frame that never arrives because we're waiting here.
+ while (_queue.size() > _maximum_queue_size && have_sequenced_image_at_queue_head()) {
+ /* The queue is too big, and the main writer thread can run and fix it, so
+ wait until it has done.
*/
_full_condition.wait (lock);
}