summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/mutex.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2015-01-09 18:59:35 +0100
committerbunnei <bunneidev@gmail.com>2015-01-09 18:59:35 +0100
commit6ae12424df58f0ea171fc75ca4b700ab1fffc192 (patch)
tree93d87f3cb19d08541c6b8f8a9e0ceb730a2b13d9 /src/core/hle/kernel/mutex.cpp
parentMerge pull request #436 from kevinhartman/system-core (diff)
parentThread: Fix nullptr access in a logging function (diff)
downloadyuzu-6ae12424df58f0ea171fc75ca4b700ab1fffc192.tar
yuzu-6ae12424df58f0ea171fc75ca4b700ab1fffc192.tar.gz
yuzu-6ae12424df58f0ea171fc75ca4b700ab1fffc192.tar.bz2
yuzu-6ae12424df58f0ea171fc75ca4b700ab1fffc192.tar.lz
yuzu-6ae12424df58f0ea171fc75ca4b700ab1fffc192.tar.xz
yuzu-6ae12424df58f0ea171fc75ca4b700ab1fffc192.tar.zst
yuzu-6ae12424df58f0ea171fc75ca4b700ab1fffc192.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/mutex.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 3dfeffc9b..7d008f6cc 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -40,14 +40,21 @@ static MutexMap g_mutex_held_locks;
* @param mutex Mutex that is to be acquired
* @param thread Thread that will acquired
*/
-void MutexAcquireLock(Mutex* mutex, Handle thread = GetCurrentThreadHandle()) {
+void MutexAcquireLock(Mutex* mutex, Handle thread = GetCurrentThread()->GetHandle()) {
g_mutex_held_locks.insert(std::make_pair(thread, mutex->GetHandle()));
mutex->lock_thread = thread;
}
-bool ReleaseMutexForThread(Mutex* mutex, Handle thread) {
- MutexAcquireLock(mutex, thread);
- Kernel::ResumeThreadFromWait(thread);
+bool ReleaseMutexForThread(Mutex* mutex, Handle thread_handle) {
+ MutexAcquireLock(mutex, thread_handle);
+
+ Thread* thread = Kernel::g_handle_table.Get<Thread>(thread_handle);
+ if (thread == nullptr) {
+ LOG_ERROR(Kernel, "Called with invalid handle: %08X", thread_handle);
+ return false;
+ }
+
+ thread->ResumeFromWait();
return true;
}
@@ -168,8 +175,8 @@ Handle CreateMutex(bool initial_locked, const std::string& name) {
ResultVal<bool> Mutex::WaitSynchronization() {
bool wait = locked;
if (locked) {
- waiting_threads.push_back(GetCurrentThreadHandle());
- Kernel::WaitCurrentThread(WAITTYPE_MUTEX, GetHandle());
+ waiting_threads.push_back(GetCurrentThread()->GetHandle());
+ Kernel::WaitCurrentThread(WAITTYPE_MUTEX, this);
} else {
// Lock the mutex when the first thread accesses it
locked = true;