mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-12 09:09:29 +01:00
Merge pull request #8217 from unknownbrackets/thread-minor
Disallow HLE thread termination in interrupts
This commit is contained in:
commit
91c095e161
1 file changed
+12
-19
@@ -2220,37 +2220,30 @@ int sceKernelTerminateDeleteThread(int threadID)
|
||||
}
|
||||
}
|
||||
|
||||
int sceKernelTerminateThread(SceUID threadID)
|
||||
{
|
||||
if (threadID == 0 || threadID == currentThread)
|
||||
{
|
||||
ERROR_LOG(SCEKERNEL, "sceKernelTerminateThread(%i): cannot terminate current thread", threadID);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_THID;
|
||||
int sceKernelTerminateThread(SceUID threadID) {
|
||||
if (__IsInInterrupt() && sceKernelGetCompiledSdkVersion() >= 0x03080000) {
|
||||
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_CONTEXT, "in interrupt");
|
||||
}
|
||||
if (threadID == 0 || threadID == currentThread) {
|
||||
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_THID, "cannot terminate current thread");
|
||||
}
|
||||
|
||||
u32 error;
|
||||
Thread *t = kernelObjects.Get<Thread>(threadID, error);
|
||||
if (t)
|
||||
{
|
||||
if (t->isStopped())
|
||||
{
|
||||
ERROR_LOG(SCEKERNEL, "sceKernelTerminateThread(%i): already stopped", threadID);
|
||||
return SCE_KERNEL_ERROR_DORMANT;
|
||||
if (t) {
|
||||
if (t->isStopped()) {
|
||||
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_DORMANT, "already stopped");
|
||||
}
|
||||
|
||||
INFO_LOG(SCEKERNEL, "sceKernelTerminateThread(%i)", threadID);
|
||||
// TODO: Should this reschedule? Seems like not.
|
||||
__KernelStopThread(threadID, SCE_KERNEL_ERROR_THREAD_TERMINATED, "thread terminated");
|
||||
|
||||
// On terminate, we reset the thread priority. On exit, we don't always (see __KernelResetThread.)
|
||||
t->nt.currentPriority = t->nt.initialPriority;
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(SCEKERNEL, "sceKernelTerminateThread(%i): thread doesn't exist", threadID);
|
||||
return error;
|
||||
return hleLogSuccessInfoI(SCEKERNEL, 0);
|
||||
} else {
|
||||
return hleLogError(SCEKERNEL, error, "thread doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user