From aa98e55a88c755759c2023e9d82d32d52d7761ea Mon Sep 17 00:00:00 2001 From: B3n30 Date: Wed, 8 Aug 2018 23:42:45 +0200 Subject: [PATCH] fixup! Service::SM: Wait till client is registered --- src/core/hle/service/sm/srv.cpp | 17 ++++++----------- src/core/hle/service/sm/srv.h | 3 +++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/core/hle/service/sm/srv.cpp b/src/core/hle/service/sm/srv.cpp index e311e79f2..a7b494bd1 100644 --- a/src/core/hle/service/sm/srv.cpp +++ b/src/core/hle/service/sm/srv.cpp @@ -3,7 +3,6 @@ // Refer to the license.txt file included. #include -#include #include "common/common_types.h" #include "common/logging/log.h" #include "core/hle/ipc.h" @@ -25,9 +24,6 @@ namespace SM { constexpr int MAX_PENDING_NOTIFICATIONS = 16; -static std::unordered_map> - get_service_handle_delayed_map; - /** * SRV::RegisterClient service function * Inputs: @@ -136,7 +132,7 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) { Kernel::SharedPtr get_service_handle_event = ctx.SleepClientThread(Kernel::GetCurrentThread(), "GetServiceHandle", std::chrono::nanoseconds(-1), get_handle); - get_service_handle_delayed_map[name] = get_service_handle_event; + get_service_handle_delayed_map[name] = std::move(get_service_handle_event); return; } else { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); @@ -232,12 +228,6 @@ void SRV::RegisterService(Kernel::HLERequestContext& ctx) { auto port = service_manager->RegisterService(name, max_sessions); - if (get_service_handle_delayed_map.find(name) != get_service_handle_delayed_map.end()) { - std::lock_guard lock(HLE::g_hle_lock); - get_service_handle_delayed_map.at(name)->Signal(); - get_service_handle_delayed_map.erase(name); - } - if (port.Failed()) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(port.Code()); @@ -245,6 +235,11 @@ void SRV::RegisterService(Kernel::HLERequestContext& ctx) { return; } + if (get_service_handle_delayed_map.find(name) != get_service_handle_delayed_map.end()) { + get_service_handle_delayed_map.at(name)->Signal(); + get_service_handle_delayed_map.erase(name); + } + IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); rb.PushMoveObjects(port.Unwrap()); diff --git a/src/core/hle/service/sm/srv.h b/src/core/hle/service/sm/srv.h index ab5855620..d3525ca65 100644 --- a/src/core/hle/service/sm/srv.h +++ b/src/core/hle/service/sm/srv.h @@ -4,6 +4,7 @@ #pragma once +#include #include "core/hle/kernel/kernel.h" #include "core/hle/service/service.h" @@ -32,6 +33,8 @@ private: std::shared_ptr service_manager; Kernel::SharedPtr notification_semaphore; + std::unordered_map> + get_service_handle_delayed_map; }; } // namespace SM