diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index 72dda6b6e7..6d85b431be 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -1331,7 +1331,7 @@ lv2_socket::lv2_socket(lv2_socket::socket_type s, s32 s_type, s32 family) lv2_socket::~lv2_socket() { - if (type != SYS_NET_SOCK_DGRAM_P2P && type != SYS_NET_SOCK_STREAM_P2P) + if (type != SYS_NET_SOCK_DGRAM_P2P && type != SYS_NET_SOCK_STREAM_P2P && socket) { #ifdef _WIN32 ::closesocket(socket); @@ -3464,8 +3464,13 @@ error_code sys_net_bnet_close(ppu_thread& ppu, s32 s) sys_net.error("CLOSE"); // If it's a bound socket we "close" the vport - if ((sock->type == SYS_NET_SOCK_DGRAM_P2P || sock->type == SYS_NET_SOCK_STREAM_P2P) && sock->p2p.port && sock->p2p.vport) + if (sock->type == SYS_NET_SOCK_DGRAM_P2P || sock->type == SYS_NET_SOCK_STREAM_P2P) { + if (!sock->p2p.port || !sock->p2p.vport) + { + return CELL_OK; + } + auto& nc = g_fxo->get(); { std::lock_guard lock(nc.list_p2p_ports_mutex); @@ -3493,9 +3498,19 @@ error_code sys_net_bnet_close(ppu_thread& ppu, s32 s) } } } + else + { + auto& dnshook = g_fxo->get(); + dnshook.remove_dns_spy(s); - auto& dnshook = g_fxo->get(); - dnshook.remove_dns_spy(s); + std::lock_guard lock(sock->mutex); +#ifdef _WIN32 + ::closesocket(sock->socket); +#else + ::close(sock->socket); +#endif + sock->socket = 0; + } return CELL_OK; }