LV2: Improve IPC support (#10206)

* Remove custom event queue's IPC management of favour of universal LV2 approach.
* Move ipc_manager to FXO.
* Fix ipc_manager internal storage memory leak: deallocate entry when IPC object destroyed.
* Rewrite lv2_obj::create to be simpler (remove many duplicated code).
* Always execute lv2_obj::create under both IPC and IDM mutexes at once (not in non-atomic single-steps). Fixing potential case where concurrency can cause IDM to contain 2 or more different objects with the same IPC key with SYS_SYNC_NOT_CARE (instead of the same object).
* Do not rely on smart ptr reference count to tell if the object exists. Use similar approach as event queues as it makes error checkings accurate.
* Optimize lv2_event_port by using std::shared_ptr for queue which wasn't allowed before.
This commit is contained in:
Eladash 2021-05-07 09:58:30 +03:00 committed by GitHub
parent a043e95d24
commit 7b6482c01d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 146 additions and 240 deletions

View file

@ -321,7 +321,7 @@ void kernel_explorer::Update()
{
auto& mutex = static_cast<lv2_mutex&>(obj);
add_leaf(node, qstr(fmt::format(u8"Mutex 0x%08x: “%s”, %s,%s Owner: %#x, Locks: %u, Key: %#llx, Conds: %u, Wq: %zu", id, lv2_obj::name64(mutex.name), mutex.protocol,
mutex.recursive == SYS_SYNC_RECURSIVE ? " Recursive," : "", mutex.owner >> 1, +mutex.lock_count, mutex.key, mutex.obj_count.load().cond_count, mutex.sq.size())));
mutex.recursive == SYS_SYNC_RECURSIVE ? " Recursive," : "", mutex.owner >> 1, +mutex.lock_count, mutex.key, mutex.cond_count, mutex.sq.size())));
break;
}
case SYS_COND_OBJECT:
@ -360,19 +360,18 @@ void kernel_explorer::Update()
case SYS_EVENT_PORT_OBJECT:
{
auto& ep = static_cast<lv2_event_port&>(obj);
const auto queue = ep.queue.lock();
const auto type = ep.type == SYS_EVENT_PORT_LOCAL ? "LOCAL"sv : "IPC"sv;
if (lv2_event_queue::check(queue))
if (const auto queue = ep.queue.get(); queue && queue->exists)
{
if (queue.get() == idm::check_unlocked<lv2_obj, lv2_event_queue>(ep.queue_id))
if (queue == idm::check_unlocked<lv2_obj, lv2_event_queue>(ep.queue_id))
{
// Type must be LOCAL here, but refer to the note below for why it is showed
add_leaf(node, qstr(fmt::format("Event Port 0x%08x: %s, Name: %#llx, Event Queue (ID): 0x%08x", id, type, ep.name, ep.queue_id)));
break;
}
if (queue == lv2_event_queue::find(queue->key))
if (queue == lv2_event_queue::find(queue->key).get())
{
// There are cases in which the attached queue by ID also has an IPC
// And the ID was destroyed but another was created for that same IPC