Merge pull request #8217 from unknownbrackets/thread-minor

Disallow HLE thread termination in interrupts
This commit is contained in:
Henrik Rydgård committed 2015-11-15 21:08:24 +01:00
commit 91c095e161
1 file changed
+12 -19
+12 -19
View File
@@ -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");
}
}