Skip to content

Commit

Permalink
Fix recvn high cpu usage
Browse files Browse the repository at this point in the history
  • Loading branch information
RipleyTom authored and Megamouse committed Mar 17, 2023
1 parent bcce3ac commit 192f482
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions rpcs3/Emu/NP/rpcn_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,13 @@ namespace rpcn
{
if (wolfSSL_want_read(read_wssl))
{
// If we received partially what we want try to wait longer
if (n_recv == 0)
return recvn_result::recvn_nodata;

pollfd poll_fd{};

while ((poll_fd.revents & POLLIN) != POLLIN && (poll_fd.revents & POLLRDNORM) != POLLRDNORM)
{
if (!connected)
return recvn_result::recvn_noconn;

if (terminate)
return recvn_result::recvn_terminate;

Expand All @@ -523,8 +522,12 @@ namespace rpcn
}

num_timeouts++;

if (num_timeouts > (RPCN_TIMEOUT / RPCN_TIMEOUT_INTERVAL))
{
if (n_recv == 0)
return recvn_result::recvn_nodata;

rpcn_log.error("recvn timeout with %d bytes received", n_recv);
return recvn_result::recvn_timeout;
}
Expand All @@ -545,6 +548,12 @@ namespace rpcn

res = 0;
}
else
{
// Reset timeout each time something is received
num_timeouts = 0;
}

n_recv += res;
}

Expand Down

0 comments on commit 192f482

Please sign in to comment.