mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 22:19:02 +00:00
Fix sys_ppu_thread_start error checking, fix rare bug in sys_ppu_thread_create
* Correct error code to EBUSY. * lv2_obj::awake was called even when EBSUY should be returned. * Fix sys_ppu_thread_create for a newly created thread with the same id as ppu_thread::id_base. (can happen if main thread exited before its creation)
This commit is contained in:
parent
c1dc6838fa
commit
dd6825a7bd
3 changed files with 23 additions and 15 deletions
|
|
@ -441,26 +441,37 @@ error_code sys_ppu_thread_start(ppu_thread& ppu, u32 thread_id)
|
|||
{
|
||||
sys_ppu_thread.trace("sys_ppu_thread_start(thread_id=0x%x)", thread_id);
|
||||
|
||||
const auto thread = idm::get<named_thread<ppu_thread>>(thread_id, [&](ppu_thread& thread)
|
||||
const auto thread = idm::get<named_thread<ppu_thread>>(thread_id, [&](ppu_thread& thread) -> CellError
|
||||
{
|
||||
if (thread.joiner == ppu_join_status::exited)
|
||||
{
|
||||
return false;
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
if (!thread.state.test_and_reset(cpu_flag::stop))
|
||||
{
|
||||
// Already started
|
||||
return CELL_EBUSY;
|
||||
}
|
||||
|
||||
lv2_obj::awake(&thread);
|
||||
return true;
|
||||
|
||||
thread.cmd_list
|
||||
({
|
||||
{ppu_cmd::opd_call, 0}, thread.entry_func
|
||||
});
|
||||
|
||||
return {};
|
||||
});
|
||||
|
||||
if (!thread || !thread.ret)
|
||||
if (!thread)
|
||||
{
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
if (!thread->state.test_and_reset(cpu_flag::stop))
|
||||
if (thread.ret)
|
||||
{
|
||||
// TODO: what happens there?
|
||||
return CELL_EPERM;
|
||||
return thread.ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue