From 8ae20c0c4d1353afe2a42f17eb14270882a89174 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 31 Dec 2009 19:49:22 +0000 Subject: stop metering thread as we disconnect a session from audioengine; explicitly drop connections early in ~Route so that we don't still have signals being handled while we destruct; fix up some valgrind warnings git-svn-id: svn://localhost/ardour2/branches/3.0@6425 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/pbd/pthread_utils.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'libs/pbd/pthread_utils.cc') diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index 34ac6fd1af..d9e5ca4078 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "pbd/pthread_utils.h" @@ -59,9 +60,9 @@ PBD::notify_gui_about_thread_creation (std::string target_gui, pthread_t thread, struct ThreadStartWithName { void* (*thread_work)(void*); void* arg; - const char* name; + std::string name; - ThreadStartWithName (void* (*f)(void*), void* a, const char* s) + ThreadStartWithName (void* (*f)(void*), void* a, const std::string& s) : thread_work (f), arg (a), name (s) {} }; @@ -72,7 +73,7 @@ fake_thread_start (void* arg) void* (*thread_work)(void*) = ts->thread_work; void* thread_arg = ts->arg; - pthread_set_name (ts->name); + pthread_set_name (ts->name.c_str()); delete ts; /* name will be deleted by the default handler for GStaticPrivate, when the thread exits */ @@ -90,10 +91,7 @@ pthread_create_and_store (string name, pthread_t *thread, void * (*start_routin pthread_attr_init(&default_attr); pthread_attr_setstacksize(&default_attr, 500000); - char* cname = new char[name.length() + 1]; - strcpy (cname, name.c_str()); - - ThreadStartWithName* ts = new ThreadStartWithName (start_routine, arg, cname); + ThreadStartWithName* ts = new ThreadStartWithName (start_routine, arg, name); if ((ret = thread_creator (thread, &default_attr, fake_thread_start, ts)) == 0) { pthread_mutex_lock (&thread_map_lock); @@ -109,8 +107,9 @@ pthread_create_and_store (string name, pthread_t *thread, void * (*start_routin void pthread_set_name (const char *str) { - /* str will be deleted when this thread exits */ - thread_name.set (const_cast(str)); + /* copy string and delete it when exiting */ + + thread_name.set (strdup (str), free); } const char * -- cgit v1.2.3