diff options
author | Robin Gareus <robin@gareus.org> | 2016-12-13 23:46:55 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-12-13 23:47:07 +0100 |
commit | fa07233a17036bc1cab69d5854b5c768ff762f5b (patch) | |
tree | 4048a4a6ca22845a9c80b0ecaf94a453b08b88da /libs/pbd/pbd/abstract_ui.cc | |
parent | 176625d9e0dbe53c9f5628d172ee6f5488be8202 (diff) |
mutex 'er up
Some overzealous locking to track down RequestObject related crashes.
bc0fa4d689a4 wrongly locked the current event loop's
request_invalidation_lock instead of the invalidation's list lock.
Also Abstract UI is able to delete requests concurrently with with
EventLoop invalidation.
e.g. PortManager::PortRegisteredOrUnregistered and GlobalPortMatrixWindow
so the lock needs to be exposed.
If this solves various issues, mutexes should to be consolidated
(request_buffer_map_lock + request_invalidation_lock) and be chosen
such that there is as little contention as possible.
Diffstat (limited to 'libs/pbd/pbd/abstract_ui.cc')
-rw-r--r-- | libs/pbd/pbd/abstract_ui.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.cc index 594dec34dd..ed358cb7cf 100644 --- a/libs/pbd/pbd/abstract_ui.cc +++ b/libs/pbd/pbd/abstract_ui.cc @@ -240,7 +240,8 @@ AbstractUI<RequestObject>::handle_ui_requests () request_buffer_map_lock.lock (); if (vec.buf[0]->invalidation) { DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1: removing invalidation record for that request\n", event_loop_name())); - Glib::Threads::Mutex::Lock lm (request_invalidation_lock); + assert (vec.buf[0]->invalidation->event_loop); + Glib::Threads::Mutex::Lock lm (vec.buf[0]->invalidation->event_loop->request_invalidation_mutex()); if (!(*i).second->dead) { vec.buf[0]->invalidation->requests.remove (vec.buf[0]); } @@ -257,6 +258,7 @@ AbstractUI<RequestObject>::handle_ui_requests () /* clean up any dead request buffers (their thread has exited) */ + Glib::Threads::Mutex::Lock lr (request_invalidation_lock); for (i = request_buffers.begin(); i != request_buffers.end(); ) { if ((*i).second->dead) { DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 deleting dead per-thread request buffer for %3 @ %4\n", @@ -304,8 +306,9 @@ AbstractUI<RequestObject>::handle_ui_requests () */ if (req->invalidation) { - Glib::Threads::Mutex::Lock lm (request_invalidation_lock); DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 remove request from its invalidation list\n", event_loop_name(), pthread_name())); + assert (req->invalidation->event_loop && req->invalidation->event_loop != this); + Glib::Threads::Mutex::Lock lm (req->invalidation->event_loop->request_invalidation_mutex()); /* after this call, if the object referenced by the * invalidation record is deleted, it will no longer |