fix rare livelock in std::map thread_buffer_requests
authorRobin Gareus <robin@gareus.org>
Sun, 14 Feb 2016 01:13:04 +0000 (02:13 +0100)
committerRobin Gareus <robin@gareus.org>
Sun, 14 Feb 2016 01:13:04 +0000 (02:13 +0100)
During initial session load it's possible that two threads call
PBD::notify_event_loops_about_thread_creation() simultaneously
(in particular the process threads). This can lead to an
endless loop in stl_tree.h when assigning thread_buffer_requests[key]

Now we only have WriteLocks.. unless some better solution comes up a
Mutex will do.

libs/pbd/event_loop.cc

index 3f5eeb0a755d3c9325fa2aa4a5162d0bf1ea8d04..08f3c2e1583ab54a365f54c067c8fd0dfa74fefc 100644 (file)
@@ -147,7 +147,7 @@ EventLoop::pre_register (const string& emitting_thread_name, uint32_t num_reques
         */
 
        ThreadBufferMapping mapping;
-       Glib::Threads::RWLock::ReaderLock lm (thread_buffer_requests_lock);
+       Glib::Threads::RWLock::WriterLock lm (thread_buffer_requests_lock);
 
        for (RequestBufferSuppliers::iterator trs = request_buffer_suppliers.begin(); trs != request_buffer_suppliers.end(); ++trs) {