mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
Split normal sockets and p2p sockets handling
This commit is contained in:
parent
b8165af054
commit
08c3a38b67
8 changed files with 203 additions and 120 deletions
|
|
@ -445,7 +445,7 @@ bool lv2_socket_p2ps::handle_listening(p2ps_encapsulated_tcp* tcp_header, [[mayb
|
|||
const u64 key_connected = (reinterpret_cast<struct sockaddr_in*>(op_addr)->sin_addr.s_addr) | (static_cast<u64>(tcp_header->src_port) << 48) | (static_cast<u64>(tcp_header->dst_port) << 32);
|
||||
|
||||
{
|
||||
auto& nc = g_fxo->get<network_context>();
|
||||
auto& nc = g_fxo->get<p2p_context>();
|
||||
auto& pport = ::at32(nc.list_p2p_ports, port);
|
||||
pport.bound_p2p_streams.emplace(key_connected, new_sock_id);
|
||||
}
|
||||
|
|
@ -593,16 +593,14 @@ s32 lv2_socket_p2ps::bind(const sys_net_sockaddr& addr)
|
|||
|
||||
socket_type real_socket{};
|
||||
|
||||
auto& nc = g_fxo->get<network_context>();
|
||||
auto& nc = g_fxo->get<p2p_context>();
|
||||
{
|
||||
std::lock_guard list_lock(nc.list_p2p_ports_mutex);
|
||||
if (!nc.list_p2p_ports.contains(p2p_port))
|
||||
{
|
||||
nc.list_p2p_ports.emplace(std::piecewise_construct, std::forward_as_tuple(p2p_port), std::forward_as_tuple(p2p_port));
|
||||
}
|
||||
|
||||
nc.create_p2p_port(p2p_port);
|
||||
auto& pport = ::at32(nc.list_p2p_ports, p2p_port);
|
||||
real_socket = pport.p2p_socket;
|
||||
|
||||
{
|
||||
// Ensures the socket & the bound list are updated at the same time to avoid races
|
||||
std::lock_guard vport_lock(pport.bound_p2p_vports_mutex);
|
||||
|
|
@ -683,14 +681,14 @@ std::optional<s32> lv2_socket_p2ps::connect(const sys_net_sockaddr& addr)
|
|||
|
||||
socket_type real_socket{};
|
||||
|
||||
auto& nc = g_fxo->get<network_context>();
|
||||
auto& nc = g_fxo->get<p2p_context>();
|
||||
{
|
||||
std::lock_guard list_lock(nc.list_p2p_ports_mutex);
|
||||
if (!nc.list_p2p_ports.contains(port))
|
||||
nc.list_p2p_ports.emplace(std::piecewise_construct, std::forward_as_tuple(port), std::forward_as_tuple(port));
|
||||
|
||||
nc.create_p2p_port(port);
|
||||
auto& pport = ::at32(nc.list_p2p_ports, port);
|
||||
real_socket = pport.p2p_socket;
|
||||
|
||||
{
|
||||
std::lock_guard lock(pport.bound_p2p_vports_mutex);
|
||||
if (vport == 0)
|
||||
|
|
@ -857,7 +855,7 @@ void lv2_socket_p2ps::close()
|
|||
return;
|
||||
}
|
||||
|
||||
auto& nc = g_fxo->get<network_context>();
|
||||
auto& nc = g_fxo->get<p2p_context>();
|
||||
{
|
||||
std::lock_guard lock(nc.list_p2p_ports_mutex);
|
||||
ensure(nc.list_p2p_ports.contains(port));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue