From a0f0f58fc595d708eb81badad32406f186da9d42 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 4 Jun 2020 09:42:04 +0300 Subject: [PATCH] sys_event_queue: Fix IPC support --- rpcs3/Emu/Cell/lv2/sys_event.cpp | 12 +++++++----- rpcs3/Emu/Cell/lv2/sys_event.h | 8 +++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_event.cpp b/rpcs3/Emu/Cell/lv2/sys_event.cpp index 248edfe5d3..dea1ff1974 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event.cpp @@ -122,22 +122,24 @@ error_code sys_event_queue_create(vm::ptr equeue_id, vm::ptr(protocol, type, attr->name_u64, event_queue_key, size); + CellError error = CELL_EAGAIN; + if (event_queue_key == SYS_EVENT_QUEUE_LOCAL) { // Not an IPC queue - if (const u32 _id = idm::import_existing(std::move(queue))) + if (const u32 _id = idm::import([&]() { if ((error = queue->on_id_create())) queue.reset(); return std::move(queue); } )) { *equeue_id = _id; return CELL_OK; } - return CELL_EAGAIN; + return error; } // Create IPC queue if (!ipc_manager::add(event_queue_key, [&]() -> std::shared_ptr { - if (const u32 _id = idm::import_existing(queue)) + if (const u32 _id = idm::import([&]() { if ((error = queue->on_id_create())) return decltype(queue){}; return queue; } )) { *equeue_id = _id; return std::move(queue); @@ -151,7 +153,7 @@ error_code sys_event_queue_create(vm::ptr equeue_id, vm::ptr exists = true; // Existence validation (workaround for shared-ptr ref-counting) + atomic_t exists = 0; // Existence validation (workaround for shared-ptr ref-counting) shared_mutex mutex; std::deque events; std::deque sq; @@ -112,6 +112,12 @@ struct lv2_event_queue final : public lv2_obj // Check queue ptr validity (use 'exists' member) static bool check(const std::weak_ptr&); static bool check(const std::shared_ptr&); + + CellError on_id_create() + { + exists++; + return {}; + } }; struct lv2_event_port final : lv2_obj