HID: Don't create an unnecessary port in CreateAppletResource.

This commit is contained in:
Subv 2018-01-22 17:41:31 -05:00
parent 1a9c96e4de
commit 1003996e80
1 changed files with 13 additions and 13 deletions

View File

@ -162,23 +162,23 @@ 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(); auto sessions = Kernel::ServerSession::CreateSessionPair(applet_resource->GetServiceName());
if (session.Succeeded()) { auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
applet_resource->ClientConnected(server);
LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u", LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u",
(*session)->GetObjectId()); client->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1}; IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap()); rb.PushMoveObjects(std::move(client));
} else {
UNIMPLEMENTED();
}
} }
}; };