Fix recvn high cpu usage
This commit is contained in:
@@ -496,14 +496,13 @@ namespace rpcn
|
|||||||
{
|
{
|
||||||
if (wolfSSL_want_read(read_wssl))
|
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{};
|
pollfd poll_fd{};
|
||||||
|
|
||||||
while ((poll_fd.revents & POLLIN) != POLLIN && (poll_fd.revents & POLLRDNORM) != POLLRDNORM)
|
while ((poll_fd.revents & POLLIN) != POLLIN && (poll_fd.revents & POLLRDNORM) != POLLRDNORM)
|
||||||
{
|
{
|
||||||
|
if (!connected)
|
||||||
|
return recvn_result::recvn_noconn;
|
||||||
|
|
||||||
if (terminate)
|
if (terminate)
|
||||||
return recvn_result::recvn_terminate;
|
return recvn_result::recvn_terminate;
|
||||||
|
|
||||||
@@ -523,8 +522,12 @@ namespace rpcn
|
|||||||
}
|
}
|
||||||
|
|
||||||
num_timeouts++;
|
num_timeouts++;
|
||||||
|
|
||||||
if (num_timeouts > (RPCN_TIMEOUT / RPCN_TIMEOUT_INTERVAL))
|
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);
|
rpcn_log.error("recvn timeout with %d bytes received", n_recv);
|
||||||
return recvn_result::recvn_timeout;
|
return recvn_result::recvn_timeout;
|
||||||
}
|
}
|
||||||
@@ -545,6 +548,12 @@ namespace rpcn
|
|||||||
|
|
||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Reset timeout each time something is received
|
||||||
|
num_timeouts = 0;
|
||||||
|
}
|
||||||
|
|
||||||
n_recv += res;
|
n_recv += res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user