1
0
Fork 0
forked from suyu/suyu

kernel/svc: Correct behavior of svcResetSignal()

While partially correct, this service call allows the retrieved event to
be null, as it also uses the same handle to check if it was referring to
a Process instance. The previous two changes put the necessary machinery
in place to allow for this, so we can simply call those member functions
here and be done with it.
This commit is contained in:
Lioncash 2018-12-04 19:59:29 -05:00
parent c7462ce712
commit 2f253986df

View file

@ -1433,17 +1433,24 @@ static ResultCode CloseHandle(Handle handle) {
return handle_table.Close(handle); return handle_table.Close(handle);
} }
/// Reset an event /// Clears the signaled state of an event or process.
static ResultCode ResetSignal(Handle handle) { static ResultCode ResetSignal(Handle handle) {
LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle);
const auto& handle_table = Core::CurrentProcess()->GetHandleTable(); const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
auto event = handle_table.Get<ReadableEvent>(handle); auto event = handle_table.Get<ReadableEvent>(handle);
if (event) {
return event->Reset();
}
ASSERT(event != nullptr); auto process = handle_table.Get<Process>(handle);
if (process) {
return process->ClearSignalState();
}
event->Clear(); LOG_ERROR(Kernel_SVC, "Invalid handle (0x{:08X})", handle);
return RESULT_SUCCESS; return ERR_INVALID_HANDLE;
} }
/// Creates a TransferMemory object /// Creates a TransferMemory object