mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
fix “no per-thread pool” abort
For some backends the process thread can change (e.g. switch coreaudio headphone + internal speakers) If there are existing x-thread event calls this can lead to the following situation: 1) SessionEvent::operator new 2) audioengine process thread change 3) SessionEvent::operator delete -> crash, wrong thread SessionEvent::operator delete can safely push the event back to the pool for later cleanup..
This commit is contained in:
parent
1a5a48436a
commit
fe85575a12
3 changed files with 6 additions and 5 deletions
|
|
@ -86,7 +86,7 @@ SessionEvent::operator new (size_t)
|
||||||
void
|
void
|
||||||
SessionEvent::operator delete (void *ptr, size_t /*size*/)
|
SessionEvent::operator delete (void *ptr, size_t /*size*/)
|
||||||
{
|
{
|
||||||
Pool* p = pool->per_thread_pool ();
|
Pool* p = pool->per_thread_pool (false);
|
||||||
SessionEvent* ev = static_cast<SessionEvent*> (ptr);
|
SessionEvent* ev = static_cast<SessionEvent*> (ptr);
|
||||||
|
|
||||||
DEBUG_TRACE (DEBUG::SessionEvents, string_compose (
|
DEBUG_TRACE (DEBUG::SessionEvents, string_compose (
|
||||||
|
|
@ -100,9 +100,10 @@ SessionEvent::operator delete (void *ptr, size_t /*size*/)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (p == ev->own_pool) {
|
if (p && p == ev->own_pool) {
|
||||||
p->release (ptr);
|
p->release (ptr);
|
||||||
} else {
|
} else {
|
||||||
|
assert(ev->own_pool);
|
||||||
ev->own_pool->push (ev);
|
ev->own_pool->push (ev);
|
||||||
DEBUG_TRACE (DEBUG::SessionEvents, string_compose ("%1 was wrong thread for this pool, pushed event onto pending list, will be deleted on next alloc from %2 pool size %3 free %4 used %5 pending %6\n",
|
DEBUG_TRACE (DEBUG::SessionEvents, string_compose ("%1 was wrong thread for this pool, pushed event onto pending list, will be deleted on next alloc from %2 pool size %3 free %4 used %5 pending %6\n",
|
||||||
pthread_name(), ev->own_pool->name(),
|
pthread_name(), ev->own_pool->name(),
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ class LIBPBD_API PerThreadPool
|
||||||
const Glib::Threads::Private<CrossThreadPool>& key() const { return _key; }
|
const Glib::Threads::Private<CrossThreadPool>& key() const { return _key; }
|
||||||
|
|
||||||
void create_per_thread_pool (std::string name, unsigned long item_size, unsigned long nitems);
|
void create_per_thread_pool (std::string name, unsigned long item_size, unsigned long nitems);
|
||||||
CrossThreadPool* per_thread_pool ();
|
CrossThreadPool* per_thread_pool (bool must_exist = true);
|
||||||
|
|
||||||
void set_trash (RingBuffer<CrossThreadPool*>* t);
|
void set_trash (RingBuffer<CrossThreadPool*>* t);
|
||||||
void add_to_trash (CrossThreadPool *);
|
void add_to_trash (CrossThreadPool *);
|
||||||
|
|
|
||||||
|
|
@ -179,10 +179,10 @@ PerThreadPool::create_per_thread_pool (string n, unsigned long isize, unsigned l
|
||||||
* calling create_per_thread_pool in the current thread.
|
* calling create_per_thread_pool in the current thread.
|
||||||
*/
|
*/
|
||||||
CrossThreadPool*
|
CrossThreadPool*
|
||||||
PerThreadPool::per_thread_pool ()
|
PerThreadPool::per_thread_pool (bool must_exist)
|
||||||
{
|
{
|
||||||
CrossThreadPool* p = _key.get();
|
CrossThreadPool* p = _key.get();
|
||||||
if (!p) {
|
if (!p && must_exist) {
|
||||||
fatal << "programming error: no per-thread pool \"" << _name << "\" for thread " << pthread_name() << endmsg;
|
fatal << "programming error: no per-thread pool \"" << _name << "\" for thread " << pthread_name() << endmsg;
|
||||||
abort(); /*NOTREACHED*/
|
abort(); /*NOTREACHED*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue