BBA/HLE: Loop over network_ref once

This commit is contained in:
Sepalani 2024-02-03 12:19:29 +04:00
parent 9e0bf29329
commit 6e2a081cb9
1 changed files with 25 additions and 26 deletions

View File

@ -658,35 +658,23 @@ void CEXIETHERNET::BuiltInBBAInterface::ReadThreadHandler(CEXIETHERNET::BuiltInB
self->m_queue_read++; self->m_queue_read++;
self->m_queue_read &= 15; self->m_queue_read &= 15;
} }
else
{ // Check network stack references
// test connections data
for (auto& net_ref : self->network_ref) for (auto& net_ref : self->network_ref)
{ {
if (net_ref.ip == 0) if (net_ref.ip == 0)
continue; continue;
const auto socket_data = self->TryGetDataFromSocket(&net_ref);
if (socket_data.has_value())
{
datasize = socket_data->size();
std::memcpy(self->m_eth_ref->mRecvBuffer.get(), socket_data->data(), datasize);
break;
}
}
}
// test and add any sleeping tcp data // Check for sleeping TCP data
for (auto& net_ref : self->network_ref) if (net_ref.type == IPPROTO_TCP)
{ {
if (net_ref.ip == 0 || net_ref.type != IPPROTO_TCP)
continue;
for (auto& tcp_buf : net_ref.tcp_buffers) for (auto& tcp_buf : net_ref.tcp_buffers)
{ {
if (!tcp_buf.used || (GetTickCountStd() - tcp_buf.tick) <= 1000) if (!tcp_buf.used || (GetTickCountStd() - tcp_buf.tick) <= 1000)
continue; continue;
tcp_buf.tick = GetTickCountStd(); tcp_buf.tick = GetTickCountStd();
// timmed out packet, resend // Timed out packet, resend
if (((self->m_queue_write + 1) & 15) != self->m_queue_read) if (((self->m_queue_write + 1) & 15) != self->m_queue_read)
{ {
self->WriteToQueue(tcp_buf.data); self->WriteToQueue(tcp_buf.data);
@ -694,6 +682,17 @@ void CEXIETHERNET::BuiltInBBAInterface::ReadThreadHandler(CEXIETHERNET::BuiltInB
} }
} }
// Check for connection data
if (datasize != 0)
continue;
const auto socket_data = self->TryGetDataFromSocket(&net_ref);
if (socket_data.has_value())
{
datasize = socket_data->size();
std::memcpy(self->m_eth_ref->mRecvBuffer.get(), socket_data->data(), datasize);
}
}
// Check for new UPnP client // Check for new UPnP client
self->HandleUPnPClient(); self->HandleUPnPClient();