aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/kernel/mutex.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-01-31 23:26:16 -0200
committerGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-02-02 15:37:08 -0200
commit52f58e64efbf43c114f701eb8f39fb463138ffb8 (patch)
treeeb40cc649b524febe841e463d6de7bce025a8105 /src/core/hle/kernel/mutex.cpp
parent7725256f649719dcce2c50ea84e79d6199dd9a50 (diff)
Kernel: Make WaitObjects share ownership of Threads waiting on them
During normal operation, a thread waiting on an WaitObject and the object hold mutual references to each other for the duration of the wait. If a process is forcefully terminated (The CTR kernel has a SVC to do this, TerminateProcess, though no equivalent exists for threads.) its threads would also be stopped and destroyed, leaving dangling pointers in the WaitObjects. The solution is to simply have the Thread remove itself from WaitObjects when it is stopped. The vector of Threads in WaitObject has also been changed to hold SharedPtrs, just in case. (Better to have a reference cycle than a crash.)
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
-rw-r--r--src/core/hle/kernel/mutex.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index c6ad5ca9..7c634f9b 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -66,7 +66,7 @@ void Mutex::Acquire() {
Acquire(GetCurrentThread());
}
-void Mutex::Acquire(Thread* thread) {
+void Mutex::Acquire(SharedPtr<Thread> thread) {
_assert_msg_(Kernel, !ShouldWait(), "object unavailable!");
if (locked)
return;
@@ -74,7 +74,7 @@ void Mutex::Acquire(Thread* thread) {
locked = true;
thread->held_mutexes.insert(this);
- holding_thread = thread;
+ holding_thread = std::move(thread);
}
void Mutex::Release() {