1
0
Fork 0

fixup! Service::SM: Wait till client is registered

This commit is contained in:
B3n30 2018-08-08 23:42:45 +02:00
parent 02a3b5ae2b
commit aa98e55a88
2 changed files with 9 additions and 11 deletions

View File

@ -3,7 +3,6 @@
// Refer to the license.txt file included.
#include <tuple>
#include <unordered_map>
#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<std::string, Kernel::SharedPtr<Kernel::Event>>
get_service_handle_delayed_map;
/**
* SRV::RegisterClient service function
* Inputs:
@ -136,7 +132,7 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) {
Kernel::SharedPtr<Kernel::Event> 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<std::recursive_mutex> 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());

View File

@ -4,6 +4,7 @@
#pragma once
#include <unordered_map>
#include "core/hle/kernel/kernel.h"
#include "core/hle/service/service.h"
@ -32,6 +33,8 @@ private:
std::shared_ptr<ServiceManager> service_manager;
Kernel::SharedPtr<Kernel::Semaphore> notification_semaphore;
std::unordered_map<std::string, Kernel::SharedPtr<Kernel::Event>>
get_service_handle_delayed_map;
};
} // namespace SM