Missing wakeups of the writer thread when we are waiting for it do something. v2.13.34
authorCarl Hetherington <cth@carlh.net>
Fri, 6 Jul 2018 22:31:35 +0000 (23:31 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 6 Jul 2018 22:31:35 +0000 (23:31 +0100)
src/lib/writer.cc

index 96fb9e179cc30b76ae5815899c4bf2f86187339f..cd5b6d7e06d36da2fa7b5e1a41f311dcd10f7913 100644 (file)
@@ -130,7 +130,9 @@ Writer::write (Data encoded, Frame frame, Eyes eyes)
        boost::mutex::scoped_lock lock (_state_mutex);
 
        while (_queued_full_in_memory > _maximum_frames_in_memory) {
        boost::mutex::scoped_lock lock (_state_mutex);
 
        while (_queued_full_in_memory > _maximum_frames_in_memory) {
-               /* There are too many full frames in memory; wait until that is sorted out */
+               /* There are too many full frames in memory; wake the main writer thread and
+                  wait until it sorts everything out */
+               _empty_condition.notify_all ();
                _full_condition.wait (lock);
        }
 
                _full_condition.wait (lock);
        }
 
@@ -175,8 +177,9 @@ Writer::repeat (Frame frame, Eyes eyes)
 
        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
 
        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.
+                  wake it and wait until it has done.
                */
                */
+               _empty_condition.notify_all ();
                _full_condition.wait (lock);
        }
 
                _full_condition.wait (lock);
        }
 
@@ -205,8 +208,9 @@ Writer::fake_write (Frame frame, Eyes eyes)
 
        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
 
        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.
+                  wake it and wait until it has done.
                */
                */
+               _empty_condition.notify_all ();
                _full_condition.wait (lock);
        }
 
                _full_condition.wait (lock);
        }