summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-01-14 10:53:32 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-01-14 10:53:32 -0500
commit35807a19293564afb742e99371d7e07b26cc8619 (patch)
tree7798aa486f8fc413b2ac32d7b2275e046eec4418 /libs
parent077c65cc2a2a058505256ea7d4c58508f3a30593 (diff)
fully clean up request buffers when a thread dies
Diffstat (limited to 'libs')
-rw-r--r--libs/pbd/event_loop.cc12
-rw-r--r--libs/pbd/pbd/abstract_ui.cc6
-rw-r--r--libs/pbd/pbd/event_loop.h1
3 files changed, 18 insertions, 1 deletions
diff --git a/libs/pbd/event_loop.cc b/libs/pbd/event_loop.cc
index e6f5414d11..424636feda 100644
--- a/libs/pbd/event_loop.cc
+++ b/libs/pbd/event_loop.cc
@@ -219,3 +219,15 @@ EventLoop::pre_register (const string& emitting_thread_name, uint32_t num_reques
}
}
+void
+EventLoop::remove_request_buffer_from_map (void* ptr)
+{
+ Glib::Threads::RWLock::ReaderLock lm (thread_buffer_requests_lock);
+
+ for (ThreadRequestBufferList::iterator x = thread_buffer_requests.begin(); x != thread_buffer_requests.end(); ++x) {
+ if (x->second.request_buffer == ptr) {
+ thread_buffer_requests.erase (x);
+ break;
+ }
+ }
+}
diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.cc
index e186161cf9..3fa1f64770 100644
--- a/libs/pbd/pbd/abstract_ui.cc
+++ b/libs/pbd/pbd/abstract_ui.cc
@@ -54,7 +54,7 @@ cleanup_request_buffer (void* ptr)
* a request. If the UI has finished processing requests, then
* we will leak this buffer object.
*/
-
+ DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("thread \"%1\" exits: marking request buffer as dead @ %2\n", pthread_name(), rb));
rb->dead = true;
}
@@ -246,9 +246,13 @@ AbstractUI<RequestObject>::handle_ui_requests ()
DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 deleting dead per-thread request buffer for %3 @ %4\n",
event_loop_name(), pthread_name(), i->second));
cerr << event_loop_name() << " noticed that a buffer was dead\n";
+ /* remove it from the EventLoop static map of all request buffers */
+ EventLoop::remove_request_buffer_from_map ((*i).second);
+ /* delete it */
delete (*i).second;
RequestBufferMapIterator tmp = i;
++tmp;
+ /* remove it from this thread's list of request buffers */
request_buffers.erase (i);
i = tmp;
} else {
diff --git a/libs/pbd/pbd/event_loop.h b/libs/pbd/pbd/event_loop.h
index f4f57f4c28..b6e07b44de 100644
--- a/libs/pbd/pbd/event_loop.h
+++ b/libs/pbd/pbd/event_loop.h
@@ -93,6 +93,7 @@ class LIBPBD_API EventLoop
static void register_request_buffer_factory (const std::string& target_thread_name, void* (*factory) (uint32_t));
static void pre_register (const std::string& emitting_thread_name, uint32_t num_requests);
+ static void remove_request_buffer_from_map (void* ptr);
private:
static Glib::Threads::Private<EventLoop> thread_event_loop;