summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/svc.cpp5
-rw-r--r--src/core/hle/kernel/thread.cpp7
-rw-r--r--src/core/hle/kernel/thread.h9
3 files changed, 19 insertions, 2 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index c63a9ba8b..b2cef3be9 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -505,6 +505,11 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
505 return RESULT_TIMEOUT; 505 return RESULT_TIMEOUT;
506 } 506 }
507 507
508 if (thread->IsSyncCancelled()) {
509 thread->SetSyncCancelled(false);
510 return ERR_SYNCHRONIZATION_CANCELED;
511 }
512
508 for (auto& object : objects) { 513 for (auto& object : objects) {
509 object->AddWaitingThread(thread); 514 object->AddWaitingThread(thread);
510 } 515 }
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 962530d2d..538e47992 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -132,8 +132,11 @@ void Thread::ResumeFromWait() {
132} 132}
133 133
134void Thread::CancelWait() { 134void Thread::CancelWait() {
135 ASSERT(GetStatus() == ThreadStatus::WaitSynch); 135 if (GetSchedulingStatus() != ThreadSchedStatus::Paused) {
136 ClearWaitObjects(); 136 is_sync_cancelled = true;
137 return;
138 }
139 is_sync_cancelled = false;
137 SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED); 140 SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED);
138 ResumeFromWait(); 141 ResumeFromWait();
139} 142}
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index c9870873d..25a6ed234 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -440,6 +440,14 @@ public:
440 is_running = value; 440 is_running = value;
441 } 441 }
442 442
443 bool IsSyncCancelled() const {
444 return is_sync_cancelled;
445 }
446
447 void SetSyncCancelled(bool value) {
448 is_sync_cancelled = value;
449 }
450
443private: 451private:
444 explicit Thread(KernelCore& kernel); 452 explicit Thread(KernelCore& kernel);
445 ~Thread() override; 453 ~Thread() override;
@@ -524,6 +532,7 @@ private:
524 532
525 u32 scheduling_state = 0; 533 u32 scheduling_state = 0;
526 bool is_running = false; 534 bool is_running = false;
535 bool is_sync_cancelled = false;
527 536
528 std::string name; 537 std::string name;
529}; 538};