Core: Fix interrupting a thread while on the thread (fixes #692)
Vicki Pfau vi@endrift.com
Wed, 28 Jun 2017 13:07:39 -0700
2 files changed,
5 insertions(+),
1 deletions(-)
M
CHANGES
→
CHANGES
@@ -73,6 +73,7 @@ - GBA Savedata: Update and fix Sharkport importing (fixes mgba.io/i/658)
- OpenGL: Fix some shaders causing offset graphics - Qt: Fix game unpausing after frame advancing and refocusing - GB Timer: Fix sub-M-cycle DIV reset timing and edge triggering + - Core: Fix interrupting a thread while on the thread (fixes mgba.io/i/692) Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers
M
src/core/thread.c
→
src/core/thread.c
@@ -401,11 +401,14 @@ }
MutexLock(&threadContext->stateMutex); ++threadContext->interruptDepth; if (threadContext->interruptDepth > 1 || !mCoreThreadIsActive(threadContext)) { + if (threadContext->state == THREAD_INTERRUPTING) { + threadContext->state = THREAD_INTERRUPTED; + } MutexUnlock(&threadContext->stateMutex); return; } threadContext->savedState = threadContext->state; - threadContext->state = THREAD_INTERRUPTING; + threadContext->state = THREAD_INTERRUPTED; ConditionWake(&threadContext->stateCond); MutexUnlock(&threadContext->stateMutex); }