Merge pull request #135 from Subv/no_ports

IPC: Don't create unnecessary ports when returning sub interfaces.
This commit is contained in:
bunnei 2018-01-22 21:37:15 -05:00 committed by GitHub
commit d1b64cdc07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 65 deletions

View file

@ -118,10 +118,11 @@ public:
if (context->IsDomain()) { if (context->IsDomain()) {
context->AddDomainObject(std::move(iface)); context->AddDomainObject(std::move(iface));
} else { } else {
auto port = iface->CreatePort(); auto sessions = Kernel::ServerSession::CreateSessionPair(iface->GetServiceName());
auto session = port->Connect(); auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
ASSERT(session.Succeeded()); auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
context->AddMoveObject(std::move(session).Unwrap()); iface->ClientConnected(server);
context->AddMoveObject(std::move(client));
} }
} }

View file

@ -162,23 +162,26 @@ public:
~Hid() = default; ~Hid() = default;
private: private:
Kernel::SharedPtr<Kernel::ClientPort> client_port; std::shared_ptr<IAppletResource> applet_resource;
void CreateAppletResource(Kernel::HLERequestContext& ctx) { void CreateAppletResource(Kernel::HLERequestContext& ctx) {
if (client_port == nullptr) { if (applet_resource == nullptr) {
client_port = std::make_shared<IAppletResource>()->CreatePort(); applet_resource = std::make_shared<IAppletResource>();
} }
auto session = client_port->Connect(); // TODO(Subv): Verify if this should return the interface as a domain object when called
if (session.Succeeded()) { // from within a domain.
LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u",
(*session)->GetObjectId()); auto sessions = Kernel::ServerSession::CreateSessionPair(applet_resource->GetServiceName());
IPC::RequestBuilder rb{ctx, 2, 0, 1}; auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
rb.Push(RESULT_SUCCESS); auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
rb.PushMoveObjects(std::move(session).Unwrap()); applet_resource->ClientConnected(server);
} else {
UNIMPLEMENTED(); LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u",
} client->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(client));
} }
}; };

View file

@ -146,18 +146,19 @@ void InstallInterfaces(SM::ServiceManager& service_manager) {
* 0: ResultCode * 0: ResultCode
*/ */
void LM::Initialize(Kernel::HLERequestContext& ctx) { void LM::Initialize(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<Logger>()->CreatePort(); // TODO(Subv): Verify if this should return the interface as a domain object when called from
auto session = client_port->Connect(); // within a domain.
if (session.Succeeded()) {
LOG_DEBUG(Service_SM, "called, initialized logger -> session=%u", auto logger = std::make_shared<Logger>();
(*session)->GetObjectId()); auto sessions = Kernel::ServerSession::CreateSessionPair(logger->GetServiceName());
IPC::RequestBuilder rb{ctx, 2, 0, 1}; auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
rb.Push(RESULT_SUCCESS); auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
rb.PushMoveObjects(std::move(session).Unwrap()); logger->ClientConnected(server);
registered_loggers.emplace_back(std::move(client_port));
} else { LOG_DEBUG(Service_SM, "called, initialized logger -> session=%u", client->GetObjectId());
UNIMPLEMENTED(); IPC::RequestBuilder rb{ctx, 2, 0, 1};
} rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(client));
LOG_INFO(Service_SM, "called"); LOG_INFO(Service_SM, "called");
} }

View file

@ -5,7 +5,6 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
@ -19,8 +18,6 @@ public:
private: private:
void Initialize(Kernel::HLERequestContext& ctx); void Initialize(Kernel::HLERequestContext& ctx);
std::vector<Kernel::SharedPtr<Kernel::ClientPort>> registered_loggers;
}; };
/// Registers all LM services with the specified service manager. /// Registers all LM services with the specified service manager.

View file

@ -83,45 +83,45 @@ private:
}; };
void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISystemClock>()->CreatePort(); // TODO(Subv): Verify if this should return the interface as a domain object when called from
auto session = client_port->Connect(); // within a domain.
if (session.Succeeded()) { auto system_clock = std::make_shared<ISystemClock>();
LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName());
(*session)->GetObjectId()); auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
IPC::RequestBuilder rb{ctx, 2, 0, 1}; auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
rb.Push(RESULT_SUCCESS); system_clock->ClientConnected(server);
rb.PushMoveObjects(std::move(session).Unwrap()); LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", client->GetObjectId());
} else { IPC::RequestBuilder rb{ctx, 2, 0, 1};
UNIMPLEMENTED(); rb.Push(RESULT_SUCCESS);
} rb.PushMoveObjects(std::move(client));
} }
void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISystemClock>()->CreatePort(); // TODO(Subv): Verify if this should return the interface as a domain object when called from
auto session = client_port->Connect(); // within a domain.
if (session.Succeeded()) { auto system_clock = std::make_shared<ISystemClock>();
LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName());
(*session)->GetObjectId()); auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
IPC::RequestBuilder rb{ctx, 2, 0, 1}; auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
rb.Push(RESULT_SUCCESS); system_clock->ClientConnected(server);
rb.PushMoveObjects(std::move(session).Unwrap()); LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", client->GetObjectId());
} else { IPC::RequestBuilder rb{ctx, 2, 0, 1};
UNIMPLEMENTED(); rb.Push(RESULT_SUCCESS);
} rb.PushMoveObjects(std::move(client));
} }
void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISteadyClock>()->CreatePort(); // TODO(Subv): Verify if this should return the interface as a domain object when called from
auto session = client_port->Connect(); // within a domain.
if (session.Succeeded()) { auto steady_clock = std::make_shared<ISteadyClock>();
LOG_DEBUG(Service, "called, initialized ISteadyClock -> session=%u", auto sessions = Kernel::ServerSession::CreateSessionPair(steady_clock->GetServiceName());
(*session)->GetObjectId()); auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
IPC::RequestBuilder rb{ctx, 2, 0, 1}; auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
rb.Push(RESULT_SUCCESS); steady_clock->ClientConnected(server);
rb.PushMoveObjects(std::move(session).Unwrap()); LOG_DEBUG(Service, "called, initialized ISteadyClock -> session=%u", client->GetObjectId());
} else { IPC::RequestBuilder rb{ctx, 2, 0, 1};
UNIMPLEMENTED(); rb.Push(RESULT_SUCCESS);
} rb.PushMoveObjects(std::move(client));
} }
void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {