mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
sys_net: fix some warnings
move some data to heap
This commit is contained in:
parent
b7fe35a2af
commit
e26d4e1762
@ -351,7 +351,7 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr>
|
||||
|
||||
const auto sock = idm::check<lv2_socket>(s, [&, notify = lv2_obj::notify_all_t()](lv2_socket& sock)
|
||||
{
|
||||
const auto [success, res, res_socket, res_addr] = sock.accept();
|
||||
auto [success, res, res_socket, res_addr] = sock.accept();
|
||||
|
||||
if (success)
|
||||
{
|
||||
@ -713,7 +713,7 @@ error_code sys_net_bnet_getsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam
|
||||
return -SYS_NET_EINVAL;
|
||||
}
|
||||
|
||||
const auto [res, out_val, out_len] = sock.getsockopt(level, optname, *optlen);
|
||||
const auto& [res, out_val, out_len] = sock.getsockopt(level, optname, *optlen);
|
||||
|
||||
if (res == CELL_OK)
|
||||
{
|
||||
@ -1277,9 +1277,9 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
|
||||
std::unique_lock nw_lock(g_fxo->get<network_context>().s_nw_mutex);
|
||||
std::shared_lock lock(id_manager::g_mutex);
|
||||
|
||||
::pollfd _fds[1024]{};
|
||||
std::vector<::pollfd> _fds(nfds);
|
||||
#ifdef _WIN32
|
||||
bool connecting[1024]{};
|
||||
std::vector<bool> connecting(nfds);
|
||||
#endif
|
||||
|
||||
for (s32 i = 0; i < nfds; i++)
|
||||
@ -1309,7 +1309,7 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
|
||||
#ifdef _WIN32
|
||||
windows_poll(_fds, nfds, 0, connecting);
|
||||
#else
|
||||
::poll(_fds, nfds, 0);
|
||||
::poll(_fds.data(), nfds, 0);
|
||||
#endif
|
||||
for (s32 i = 0; i < nfds; i++)
|
||||
{
|
||||
@ -1330,7 +1330,7 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
|
||||
{
|
||||
lock.unlock();
|
||||
nw_lock.unlock();
|
||||
std::memcpy(fds.get_ptr(), fds_buf.data(), nfds * sizeof(fds[0]));
|
||||
std::memcpy(fds.get_ptr(), fds_buf.data(), nfds * sizeof(sys_net_pollfd));
|
||||
return not_an_error(signaled);
|
||||
}
|
||||
|
||||
@ -1473,9 +1473,9 @@ error_code sys_net_bnet_select(ppu_thread& ppu, s32 nfds, vm::ptr<sys_net_fd_set
|
||||
|
||||
reader_lock lock(id_manager::g_mutex);
|
||||
|
||||
::pollfd _fds[1024]{};
|
||||
std::vector<::pollfd> _fds(nfds);
|
||||
#ifdef _WIN32
|
||||
bool connecting[1024]{};
|
||||
std::vector<bool> connecting(nfds);
|
||||
#endif
|
||||
|
||||
for (s32 i = 0; i < nfds; i++)
|
||||
@ -1536,7 +1536,7 @@ error_code sys_net_bnet_select(ppu_thread& ppu, s32 nfds, vm::ptr<sys_net_fd_set
|
||||
#ifdef _WIN32
|
||||
windows_poll(_fds, nfds, 0, connecting);
|
||||
#else
|
||||
::poll(_fds, nfds, 0);
|
||||
::poll(_fds.data(), nfds, 0);
|
||||
#endif
|
||||
for (s32 i = 0; i < nfds; i++)
|
||||
{
|
||||
|
@ -984,7 +984,7 @@ std::optional<s32> lv2_socket_native::sendto(s32 flags, const std::vector<u8>& b
|
||||
}
|
||||
}
|
||||
|
||||
native_result = ::sendto(socket, reinterpret_cast<const char*>(buf.data()), buf.size(), native_flags, native_addr ? reinterpret_cast<struct sockaddr*>(&(*native_addr)) : nullptr, native_addr ? sizeof(*native_addr) : 0);
|
||||
native_result = ::sendto(socket, reinterpret_cast<const char*>(buf.data()), buf.size(), native_flags, native_addr ? reinterpret_cast<struct sockaddr*>(&native_addr.value()) : nullptr, native_addr ? sizeof(sockaddr_in) : 0);
|
||||
|
||||
if (native_result >= 0)
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ std::optional<s32> lv2_socket_p2p::sendto(s32 flags, const std::vector<u8>& buf,
|
||||
|
||||
ensure(opt_sn_addr);
|
||||
ensure(socket); // ensures it has been bound
|
||||
ensure(buf.size() <= (65535 - VPORT_P2P_HEADER_SIZE)); // catch games using full payload for future fragmentation implementation if necessary
|
||||
ensure(buf.size() <= static_cast<usz>(65535 - VPORT_P2P_HEADER_SIZE)); // catch games using full payload for future fragmentation implementation if necessary
|
||||
const u16 p2p_port = reinterpret_cast<const sys_net_sockaddr_in*>(&*opt_sn_addr)->sin_port;
|
||||
const u16 p2p_vport = reinterpret_cast<const sys_net_sockaddr_in_p2p*>(&*opt_sn_addr)->sin_vport;
|
||||
|
||||
|
@ -96,27 +96,29 @@ void network_thread::operator()()
|
||||
|
||||
s_to_awake.clear();
|
||||
|
||||
::pollfd fds[lv2_socket::id_count]{};
|
||||
std::vector<::pollfd> fds(lv2_socket::id_count);
|
||||
#ifdef _WIN32
|
||||
bool connecting[lv2_socket::id_count]{};
|
||||
bool was_connecting[lv2_socket::id_count]{};
|
||||
std::vector<bool> connecting(lv2_socket::id_count);
|
||||
std::vector<bool> was_connecting(lv2_socket::id_count);
|
||||
#endif
|
||||
|
||||
::pollfd p2p_fd[lv2_socket::id_count]{};
|
||||
std::vector<::pollfd> p2p_fd(lv2_socket::id_count);
|
||||
|
||||
while (thread_ctrl::state() != thread_state::aborting)
|
||||
{
|
||||
ensure(socklist.size() <= lv2_socket::id_count);
|
||||
|
||||
// Wait with 1ms timeout
|
||||
#ifdef _WIN32
|
||||
windows_poll(fds, ::size32(socklist), 1, connecting);
|
||||
windows_poll(fds, socklist.size(), 1, connecting);
|
||||
#else
|
||||
::poll(fds, socklist.size(), 1);
|
||||
::poll(fds.data(), socklist.size(), 1);
|
||||
#endif
|
||||
|
||||
// Check P2P sockets for incoming packets(timeout could probably be set at 0)
|
||||
{
|
||||
std::lock_guard lock(list_p2p_ports_mutex);
|
||||
std::memset(p2p_fd, 0, sizeof(p2p_fd));
|
||||
std::memset(p2p_fd.data(), 0, p2p_fd.size() * sizeof(::pollfd));
|
||||
auto num_p2p_sockets = 0;
|
||||
for (const auto& p2p_port : list_p2p_ports)
|
||||
{
|
||||
@ -129,9 +131,9 @@ void network_thread::operator()()
|
||||
if (num_p2p_sockets)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const auto ret_p2p = WSAPoll(p2p_fd, num_p2p_sockets, 1);
|
||||
const auto ret_p2p = WSAPoll(p2p_fd.data(), num_p2p_sockets, 1);
|
||||
#else
|
||||
const auto ret_p2p = ::poll(p2p_fd, num_p2p_sockets, 1);
|
||||
const auto ret_p2p = ::poll(p2p_fd.data(), num_p2p_sockets, 1);
|
||||
#endif
|
||||
if (ret_p2p > 0)
|
||||
{
|
||||
|
@ -189,12 +189,13 @@ s32 network_clear_queue(ppu_thread& ppu)
|
||||
|
||||
#ifdef _WIN32
|
||||
// Workaround function for WSAPoll not reporting failed connections
|
||||
void windows_poll(pollfd* fds, unsigned long nfds, int timeout, bool* connecting)
|
||||
void windows_poll(std::vector<pollfd>& fds, unsigned long nfds, int timeout, std::vector<bool>& connecting)
|
||||
{
|
||||
ensure(connecting);
|
||||
ensure(fds.size() >= nfds);
|
||||
ensure(connecting.size() >= nfds);
|
||||
|
||||
// Don't call WSAPoll with zero nfds (errors 10022 or 10038)
|
||||
if (std::none_of(fds, fds + nfds, [](pollfd& pfd)
|
||||
if (std::none_of(fds.begin(), fds.begin() + nfds, [](pollfd& pfd)
|
||||
{
|
||||
return pfd.fd != INVALID_SOCKET;
|
||||
}))
|
||||
@ -207,7 +208,7 @@ void windows_poll(pollfd* fds, unsigned long nfds, int timeout, bool* connecting
|
||||
return;
|
||||
}
|
||||
|
||||
int r = ::WSAPoll(fds, nfds, timeout);
|
||||
int r = ::WSAPoll(fds.data(), nfds, timeout);
|
||||
|
||||
if (r == SOCKET_ERROR)
|
||||
{
|
||||
|
@ -26,5 +26,5 @@ bool is_ip_public_address(const ::sockaddr_in& addr);
|
||||
s32 network_clear_queue(ppu_thread& ppu);
|
||||
|
||||
#ifdef _WIN32
|
||||
void windows_poll(pollfd* fds, unsigned long nfds, int timeout, bool* connecting);
|
||||
void windows_poll(std::vector<pollfd>& fds, unsigned long nfds, int timeout, std::vector<bool>& connecting);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user