mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01:00
Add mutex lock for NP changes
This commit is contained in:
parent
81270f3142
commit
8be2a55ccc
@ -401,6 +401,8 @@ error_code sceNpInit(u32 poolsize, vm::ptr<void> poolptr)
|
||||
|
||||
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
||||
|
||||
std::lock_guard lock(nph->mutex_status);
|
||||
|
||||
if (nph->is_NP_init)
|
||||
{
|
||||
return SCE_NP_ERROR_ALREADY_INITIALIZED;
|
||||
@ -432,6 +434,8 @@ error_code sceNpTerm()
|
||||
|
||||
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
||||
|
||||
std::lock_guard lock(nph->mutex_status);
|
||||
|
||||
if (!nph->is_NP_init)
|
||||
{
|
||||
return SCE_NP_ERROR_NOT_INITIALIZED;
|
||||
|
@ -209,9 +209,12 @@ error_code sceNp2Init(u32 poolsize, vm::ptr<void> poolptr)
|
||||
|
||||
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
||||
|
||||
if (nph->is_NP2_init)
|
||||
{
|
||||
return SCE_NP_ERROR_ALREADY_INITIALIZED;
|
||||
std::lock_guard lock(nph->mutex_status);
|
||||
if (nph->is_NP2_init)
|
||||
{
|
||||
return SCE_NP_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
}
|
||||
|
||||
const u32 result = std::bit_cast<u32>(sceNpInit(poolsize, poolptr));
|
||||
@ -264,9 +267,12 @@ error_code sceNp2Term(ppu_thread& ppu)
|
||||
|
||||
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
||||
|
||||
if (!nph->is_NP2_init)
|
||||
{
|
||||
return SCE_NP_ERROR_NOT_INITIALIZED;
|
||||
std::lock_guard lock(nph->mutex_status);
|
||||
if (!nph->is_NP2_init)
|
||||
{
|
||||
return SCE_NP_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: does this return on error_code ?
|
||||
@ -291,20 +297,23 @@ error_code sceNpMatching2Term2()
|
||||
|
||||
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
||||
|
||||
if (!nph->is_NP2_init)
|
||||
{
|
||||
return SCE_NP_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
std::lock_guard lock(nph->mutex_status);
|
||||
if (!nph->is_NP2_init)
|
||||
{
|
||||
return SCE_NP_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
if (!nph->is_NP2_Match2_init)
|
||||
{
|
||||
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
|
||||
if (!nph->is_NP2_Match2_init)
|
||||
{
|
||||
return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nph->is_NP2_Match2_init = false;
|
||||
}
|
||||
|
||||
// TODO: for all contexts: sceNpMatching2DestroyContext
|
||||
|
||||
nph->is_NP2_Match2_init = false;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,9 @@ public:
|
||||
// For signaling
|
||||
void req_sign_infos(const std::string& npid, u32 conn_id);
|
||||
|
||||
// Mutex for NP status change
|
||||
shared_mutex mutex_status;
|
||||
|
||||
static constexpr std::string_view thread_name = "NP Handler Thread";
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user