diff options
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 12 |
3 files changed, 17 insertions, 7 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index d48a2203a..b25190882 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -518,16 +518,14 @@ static ResultCode CancelSynchronization(Core::System& system, Handle thread_hand | |||
| 518 | LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); | 518 | LOG_TRACE(Kernel_SVC, "called thread=0x{:X}", thread_handle); |
| 519 | 519 | ||
| 520 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 520 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 521 | const SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 521 | SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); |
| 522 | if (!thread) { | 522 | if (!thread) { |
| 523 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", | 523 | LOG_ERROR(Kernel_SVC, "Thread handle does not exist, thread_handle=0x{:08X}", |
| 524 | thread_handle); | 524 | thread_handle); |
| 525 | return ERR_INVALID_HANDLE; | 525 | return ERR_INVALID_HANDLE; |
| 526 | } | 526 | } |
| 527 | 527 | ||
| 528 | ASSERT(thread->GetStatus() == ThreadStatus::WaitSynchAny); | 528 | thread->CancelWait(); |
| 529 | thread->SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED); | ||
| 530 | thread->ResumeFromWait(); | ||
| 531 | return RESULT_SUCCESS; | 529 | return RESULT_SUCCESS; |
| 532 | } | 530 | } |
| 533 | 531 | ||
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index ca52267b2..7d4fe9608 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -142,6 +142,12 @@ void Thread::ResumeFromWait() { | |||
| 142 | ChangeScheduler(); | 142 | ChangeScheduler(); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | void Thread::CancelWait() { | ||
| 146 | ASSERT(GetStatus() == ThreadStatus::WaitSynchAny); | ||
| 147 | SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED); | ||
| 148 | ResumeFromWait(); | ||
| 149 | } | ||
| 150 | |||
| 145 | /** | 151 | /** |
| 146 | * Resets a thread context, making it ready to be scheduled and run by the CPU | 152 | * Resets a thread context, making it ready to be scheduled and run by the CPU |
| 147 | * @param context Thread context to reset | 153 | * @param context Thread context to reset |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 32026d7f0..e3c457408 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -164,11 +164,17 @@ public: | |||
| 164 | return tls_memory; | 164 | return tls_memory; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | /** | 167 | /// Resumes a thread from waiting |
| 168 | * Resumes a thread from waiting | ||
| 169 | */ | ||
| 170 | void ResumeFromWait(); | 168 | void ResumeFromWait(); |
| 171 | 169 | ||
| 170 | /// Cancels a waiting operation that this thread may or may not be within. | ||
| 171 | /// | ||
| 172 | /// When the thread is within a waiting state, this will set the thread's | ||
| 173 | /// waiting result to signal a canceled wait. The function will then resume | ||
| 174 | /// this thread. | ||
| 175 | /// | ||
| 176 | void CancelWait(); | ||
| 177 | |||
| 172 | /** | 178 | /** |
| 173 | * Schedules an event to wake up the specified thread after the specified delay | 179 | * Schedules an event to wake up the specified thread after the specified delay |
| 174 | * @param nanoseconds The time this thread will be allowed to sleep for | 180 | * @param nanoseconds The time this thread will be allowed to sleep for |