Postpone thread launching on g_fxo->init

This commit is contained in:
Eladash 2023-12-14 22:20:21 +02:00 committed by Elad Ashkenazi
parent a4bcba8971
commit 0c410f8a14
11 changed files with 112 additions and 44 deletions

View file

@ -339,6 +339,28 @@ namespace np
return;
}
extern void init_np_handler_dependencies()
{
if (auto handler = g_fxo->try_get<named_thread<np_handler>>())
{
handler->init_np_handler_dependencies();
}
}
void np_handler::init_np_handler_dependencies()
{
if (is_psn_active && g_cfg.net.psn_status == np_psn_status::psn_rpcn && g_fxo->is_init<network_context>() && !m_inited_np_handler_dependencies)
{
m_inited_np_handler_dependencies = true;
auto& nc = g_fxo->get<network_context>();
nc.bind_sce_np_port();
std::lock_guard lock(mutex_rpcn);
rpcn = rpcn::rpcn_client::get_instance();
}
}
np_handler::np_handler()
{
g_fxo->need<named_thread<signaling_handler>>();
@ -388,16 +410,6 @@ namespace np
if (g_cfg.net.upnp_enabled)
upnp.upnp_enable();
}
if (is_psn_active && g_cfg.net.psn_status == np_psn_status::psn_rpcn)
{
g_fxo->need<network_context>();
auto& nc = g_fxo->get<network_context>();
nc.bind_sce_np_port();
std::lock_guard lock(mutex_rpcn);
rpcn = rpcn::rpcn_client::get_instance();
}
}
np_handler::np_handler(utils::serial& ar)