BBA/HLE: Move polling data logic into a method
This commit is contained in:
parent
fbebbcc0fd
commit
f3194b777b
|
@ -128,6 +128,40 @@ void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(const std::vector<u8>& data
|
||||||
m_queue_write = next_write_index;
|
m_queue_write = next_write_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEXIETHERNET::BuiltInBBAInterface::PollData(std::size_t* datasize)
|
||||||
|
{
|
||||||
|
for (auto& net_ref : network_ref)
|
||||||
|
{
|
||||||
|
if (net_ref.ip == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Check for sleeping TCP data
|
||||||
|
if (net_ref.type == IPPROTO_TCP)
|
||||||
|
{
|
||||||
|
for (auto& tcp_buf : net_ref.tcp_buffers)
|
||||||
|
{
|
||||||
|
if (!tcp_buf.used || (GetTickCountStd() - tcp_buf.tick) <= 1000)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
tcp_buf.tick = GetTickCountStd();
|
||||||
|
// Timed out packet, resend
|
||||||
|
if (((m_queue_write + 1) & 15) != m_queue_read)
|
||||||
|
WriteToQueue(tcp_buf.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for connection data
|
||||||
|
if (*datasize != 0)
|
||||||
|
continue;
|
||||||
|
const auto socket_data = TryGetDataFromSocket(&net_ref);
|
||||||
|
if (socket_data.has_value())
|
||||||
|
{
|
||||||
|
*datasize = socket_data->size();
|
||||||
|
std::memcpy(m_eth_ref->mRecvBuffer.get(), socket_data->data(), *datasize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CEXIETHERNET::BuiltInBBAInterface::HandleARP(const Common::ARPPacket& packet)
|
void CEXIETHERNET::BuiltInBBAInterface::HandleARP(const Common::ARPPacket& packet)
|
||||||
{
|
{
|
||||||
const auto& [hwdata, arpdata] = packet;
|
const auto& [hwdata, arpdata] = packet;
|
||||||
|
@ -657,38 +691,7 @@ void CEXIETHERNET::BuiltInBBAInterface::ReadThreadHandler(CEXIETHERNET::BuiltInB
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check network stack references
|
// Check network stack references
|
||||||
for (auto& net_ref : self->network_ref)
|
self->PollData(&datasize);
|
||||||
{
|
|
||||||
if (net_ref.ip == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Check for sleeping TCP data
|
|
||||||
if (net_ref.type == IPPROTO_TCP)
|
|
||||||
{
|
|
||||||
for (auto& tcp_buf : net_ref.tcp_buffers)
|
|
||||||
{
|
|
||||||
if (!tcp_buf.used || (GetTickCountStd() - tcp_buf.tick) <= 1000)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
tcp_buf.tick = GetTickCountStd();
|
|
||||||
// Timed out packet, resend
|
|
||||||
if (((self->m_queue_write + 1) & 15) != self->m_queue_read)
|
|
||||||
{
|
|
||||||
self->WriteToQueue(tcp_buf.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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();
|
||||||
|
|
|
@ -463,6 +463,7 @@ private:
|
||||||
static void ReadThreadHandler(BuiltInBBAInterface* self);
|
static void ReadThreadHandler(BuiltInBBAInterface* self);
|
||||||
#endif
|
#endif
|
||||||
void WriteToQueue(const std::vector<u8>& data);
|
void WriteToQueue(const std::vector<u8>& data);
|
||||||
|
void PollData(std::size_t* datasize);
|
||||||
std::optional<std::vector<u8>> TryGetDataFromSocket(StackRef* ref);
|
std::optional<std::vector<u8>> TryGetDataFromSocket(StackRef* ref);
|
||||||
|
|
||||||
void HandleARP(const Common::ARPPacket& packet);
|
void HandleARP(const Common::ARPPacket& packet);
|
||||||
|
|
Loading…
Reference in New Issue