mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
fix lv2_socket_native::accept
This commit is contained in:
parent
bec0b6e8c3
commit
3dc9a8b980
@ -273,15 +273,17 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr>
|
||||
|
||||
s32 result = 0;
|
||||
sys_net_sockaddr sn_addr{};
|
||||
std::shared_ptr<lv2_socket> new_socket{};
|
||||
|
||||
const auto sock = idm::check<lv2_socket>(s, [&](lv2_socket& sock)
|
||||
{
|
||||
const auto [success, res, res_addr] = sock.accept();
|
||||
const auto [success, res, res_socket, res_addr] = sock.accept();
|
||||
|
||||
if (success)
|
||||
{
|
||||
result = res;
|
||||
sn_addr = res_addr;
|
||||
new_socket = std::move(res_socket);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -289,11 +291,12 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr>
|
||||
{
|
||||
if (events & lv2_socket::poll_t::read)
|
||||
{
|
||||
auto [success, res, res_addr] = sock.accept(false);
|
||||
auto [success, res, res_socket, res_addr] = sock.accept(false);
|
||||
if (success)
|
||||
{
|
||||
result = res;
|
||||
sn_addr = res_addr;
|
||||
new_socket = std::move(res_socket);
|
||||
lv2_obj::awake(&ppu);
|
||||
return success;
|
||||
}
|
||||
@ -345,6 +348,18 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr>
|
||||
return sys_net_error{result};
|
||||
}
|
||||
|
||||
s32 id_ps3 = result;
|
||||
|
||||
if (!id_ps3)
|
||||
{
|
||||
ensure(new_socket);
|
||||
id_ps3 = idm::import_existing<lv2_socket>(new_socket);
|
||||
if (id_ps3 == id_manager::id_traits<lv2_socket>::invalid)
|
||||
{
|
||||
return -SYS_NET_EMFILE;
|
||||
}
|
||||
}
|
||||
|
||||
if (ppu.is_stopped())
|
||||
{
|
||||
return {};
|
||||
@ -357,7 +372,7 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr>
|
||||
}
|
||||
|
||||
// Socket ID
|
||||
return not_an_error(result);
|
||||
return not_an_error(id_ps3);
|
||||
}
|
||||
|
||||
error_code sys_net_bnet_bind(ppu_thread& ppu, s32 s, vm::cptr<sys_net_sockaddr> addr, u32 addrlen)
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
#endif
|
||||
|
||||
public:
|
||||
virtual std::tuple<bool, s32, sys_net_sockaddr> accept(bool is_lock = true) = 0;
|
||||
virtual std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> accept(bool is_lock = true) = 0;
|
||||
virtual s32 bind(const sys_net_sockaddr& addr, s32 ps3_id) = 0;
|
||||
|
||||
virtual std::optional<s32> connect(const sys_net_sockaddr& addr) = 0;
|
||||
|
@ -62,7 +62,7 @@ void lv2_socket_native::set_socket(socket_type socket, lv2_socket_family family,
|
||||
set_non_blocking();
|
||||
}
|
||||
|
||||
std::tuple<bool, s32, sys_net_sockaddr> lv2_socket_native::accept(bool is_lock)
|
||||
std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> lv2_socket_native::accept(bool is_lock)
|
||||
{
|
||||
std::unique_lock<shared_mutex> lock(mutex, std::defer_lock);
|
||||
|
||||
@ -80,24 +80,18 @@ std::tuple<bool, s32, sys_net_sockaddr> lv2_socket_native::accept(bool is_lock)
|
||||
{
|
||||
auto newsock = std::make_shared<lv2_socket_native>(family, type, protocol);
|
||||
newsock->set_socket(native_socket, family, type, protocol);
|
||||
s32 id_ps3 = idm::import_existing<lv2_socket>(newsock);
|
||||
|
||||
if (id_ps3 == id_manager::id_traits<lv2_socket>::invalid)
|
||||
{
|
||||
return {true, -SYS_NET_EMFILE, {}};
|
||||
}
|
||||
|
||||
sys_net_sockaddr ps3_addr = native_addr_to_sys_net_addr(native_addr);
|
||||
|
||||
return {true, id_ps3, ps3_addr};
|
||||
return {true, 0, std::move(newsock), ps3_addr};
|
||||
}
|
||||
|
||||
if (auto result = get_last_error(!so_nbio); result)
|
||||
{
|
||||
return {true, -result, {}};
|
||||
return {true, -result, {}, {}};
|
||||
}
|
||||
|
||||
return {false, {}, {}};
|
||||
return {false, {}, {}, {}};
|
||||
}
|
||||
|
||||
s32 lv2_socket_native::bind(const sys_net_sockaddr& addr, [[maybe_unused]] s32 ps3_id)
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
~lv2_socket_native();
|
||||
s32 create_socket();
|
||||
|
||||
std::tuple<bool, s32, sys_net_sockaddr> accept(bool is_lock = true) override;
|
||||
std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> accept(bool is_lock = true) override;
|
||||
s32 bind(const sys_net_sockaddr& addr, s32 ps3_id) override;
|
||||
|
||||
std::optional<s32> connect(const sys_net_sockaddr& addr) override;
|
||||
|
@ -39,7 +39,7 @@ void lv2_socket_p2p::handle_new_data(sys_net_sockaddr_in_p2p p2p_addr, std::vect
|
||||
}
|
||||
}
|
||||
|
||||
std::tuple<bool, s32, sys_net_sockaddr> lv2_socket_p2p::accept([[maybe_unused]] bool is_lock)
|
||||
std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> lv2_socket_p2p::accept([[maybe_unused]] bool is_lock)
|
||||
{
|
||||
sys_net.fatal("[P2P] accept() called on a P2P socket");
|
||||
return {};
|
||||
|
@ -7,7 +7,7 @@ class lv2_socket_p2p : public lv2_socket
|
||||
public:
|
||||
lv2_socket_p2p(lv2_socket_family family, lv2_socket_type type, lv2_ip_protocol protocol);
|
||||
|
||||
std::tuple<bool, s32, sys_net_sockaddr> accept(bool is_lock = true) override;
|
||||
std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> accept(bool is_lock = true) override;
|
||||
s32 bind(const sys_net_sockaddr& addr, s32 ps3_id) override;
|
||||
|
||||
std::optional<s32> connect(const sys_net_sockaddr& addr) override;
|
||||
|
@ -481,7 +481,7 @@ void lv2_socket_p2ps::set_status(p2ps_stream_status new_status)
|
||||
status = new_status;
|
||||
}
|
||||
|
||||
std::tuple<bool, s32, sys_net_sockaddr> lv2_socket_p2ps::accept(bool is_lock)
|
||||
std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> lv2_socket_p2ps::accept(bool is_lock)
|
||||
{
|
||||
std::unique_lock<shared_mutex> lock(mutex, std::defer_lock);
|
||||
|
||||
@ -494,10 +494,10 @@ std::tuple<bool, s32, sys_net_sockaddr> lv2_socket_p2ps::accept(bool is_lock)
|
||||
{
|
||||
if (so_nbio)
|
||||
{
|
||||
return {true, -SYS_NET_EWOULDBLOCK, {}};
|
||||
return {true, -SYS_NET_EWOULDBLOCK, {}, {}};
|
||||
}
|
||||
|
||||
return {false, {}, {}};
|
||||
return {false, {}, {}, {}};
|
||||
}
|
||||
|
||||
auto p2ps_client = backlog.front();
|
||||
@ -516,7 +516,7 @@ std::tuple<bool, s32, sys_net_sockaddr> lv2_socket_p2ps::accept(bool is_lock)
|
||||
paddr->sin_len = sizeof(sys_net_sockaddr_in_p2p);
|
||||
}
|
||||
|
||||
return {true, p2ps_client, ps3_addr};
|
||||
return {true, p2ps_client, {}, ps3_addr};
|
||||
}
|
||||
|
||||
s32 lv2_socket_p2ps::bind(const sys_net_sockaddr& addr, s32 ps3_id)
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
bool handle_listening(p2ps_encapsulated_tcp* tcp_header, u8* data, ::sockaddr_storage* op_addr);
|
||||
void send_u2s_packet(std::vector<u8> data, const ::sockaddr_in* dst, u32 seq, bool require_ack);
|
||||
|
||||
std::tuple<bool, s32, sys_net_sockaddr> accept(bool is_lock = true) override;
|
||||
std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> accept(bool is_lock = true) override;
|
||||
s32 bind(const sys_net_sockaddr& addr, s32 ps3_id) override;
|
||||
|
||||
std::optional<s32> connect(const sys_net_sockaddr& addr) override;
|
||||
|
@ -8,7 +8,7 @@ lv2_socket_raw::lv2_socket_raw(lv2_socket_family family, lv2_socket_type type, l
|
||||
{
|
||||
}
|
||||
|
||||
std::tuple<bool, s32, sys_net_sockaddr> lv2_socket_raw::accept([[maybe_unused]] bool is_lock)
|
||||
std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> lv2_socket_raw::accept([[maybe_unused]] bool is_lock)
|
||||
{
|
||||
sys_net.todo("lv2_socket_raw::accept");
|
||||
return {};
|
||||
|
@ -7,7 +7,7 @@ class lv2_socket_raw final : public lv2_socket
|
||||
public:
|
||||
lv2_socket_raw(lv2_socket_family family, lv2_socket_type type, lv2_ip_protocol protocol);
|
||||
|
||||
std::tuple<bool, s32, sys_net_sockaddr> accept(bool is_lock = true) override;
|
||||
std::tuple<bool, s32, std::shared_ptr<lv2_socket>, sys_net_sockaddr> accept(bool is_lock = true) override;
|
||||
s32 bind(const sys_net_sockaddr& addr, s32 ps3_id) override;
|
||||
|
||||
std::optional<s32> connect(const sys_net_sockaddr& addr) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user