1
0
Fork 0
forked from suyu/suyu

hle: service: Implement IPC::CommandType::Close.

- This was not actually closing sessions before.
This commit is contained in:
bunnei 2021-05-10 16:05:37 -07:00
parent 41928dfdda
commit da25a59866
3 changed files with 15 additions and 11 deletions

View file

@ -95,7 +95,7 @@ ResultCode KServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& co
UNREACHABLE(); UNREACHABLE();
return RESULT_SUCCESS; // Ignore error if asserts are off return RESULT_SUCCESS; // Ignore error if asserts are off
} }
return domain_request_handlers[object_id - 1]->HandleSyncRequest(context); return domain_request_handlers[object_id - 1]->HandleSyncRequest(*this, context);
case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: { case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: {
LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x{:08X}", object_id); LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x{:08X}", object_id);
@ -135,7 +135,7 @@ ResultCode KServerSession::CompleteSyncRequest(HLERequestContext& context) {
// If there is no domain header, the regular session handler is used // If there is no domain header, the regular session handler is used
} else if (hle_handler != nullptr) { } else if (hle_handler != nullptr) {
// If this ServerSession has an associated HLE handler, forward the request to it. // If this ServerSession has an associated HLE handler, forward the request to it.
result = hle_handler->HandleSyncRequest(context); result = hle_handler->HandleSyncRequest(*this, context);
} }
if (convert_to_domain) { if (convert_to_domain) {

View file

@ -167,33 +167,36 @@ void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) {
handler_invoker(this, info->handler_callback, ctx); handler_invoker(this, info->handler_callback, ctx);
} }
ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context) { ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session,
Kernel::HLERequestContext& ctx) {
const auto guard = LockService(); const auto guard = LockService();
switch (context.GetCommandType()) { switch (ctx.GetCommandType()) {
case IPC::CommandType::Close: { case IPC::CommandType::Close:
IPC::ResponseBuilder rb{context, 2}; case IPC::CommandType::TIPC_Close: {
session.Close();
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
return IPC::ERR_REMOTE_PROCESS_DEAD; return IPC::ERR_REMOTE_PROCESS_DEAD;
} }
case IPC::CommandType::ControlWithContext: case IPC::CommandType::ControlWithContext:
case IPC::CommandType::Control: { case IPC::CommandType::Control: {
system.ServiceManager().InvokeControlRequest(context); system.ServiceManager().InvokeControlRequest(ctx);
break; break;
} }
case IPC::CommandType::RequestWithContext: case IPC::CommandType::RequestWithContext:
case IPC::CommandType::Request: { case IPC::CommandType::Request: {
InvokeRequest(context); InvokeRequest(ctx);
break; break;
} }
default: default:
UNIMPLEMENTED_MSG("command_type={}", context.GetCommandType()); UNIMPLEMENTED_MSG("command_type={}", ctx.GetCommandType());
} }
// If emulation was shutdown, we are closing service threads, do not write the response back to // If emulation was shutdown, we are closing service threads, do not write the response back to
// memory that may be shutting down as well. // memory that may be shutting down as well.
if (system.IsPoweredOn()) { if (system.IsPoweredOn()) {
context.WriteToOutgoingCommandBuffer(context.GetThread()); ctx.WriteToOutgoingCommandBuffer(ctx.GetThread());
} }
return RESULT_SUCCESS; return RESULT_SUCCESS;

View file

@ -71,7 +71,8 @@ public:
Kernel::KClientPort& CreatePort(Kernel::KernelCore& kernel); Kernel::KClientPort& CreatePort(Kernel::KernelCore& kernel);
/// Handles a synchronization request for the service. /// Handles a synchronization request for the service.
ResultCode HandleSyncRequest(Kernel::HLERequestContext& context) override; ResultCode HandleSyncRequest(Kernel::KServerSession& session,
Kernel::HLERequestContext& context) override;
protected: protected:
/// Member-function pointer type of SyncRequest handlers. /// Member-function pointer type of SyncRequest handlers.