mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-13 07:49:19 +01:00
BBA/HLE: Check queue overrun
This commit is contained in:
parent
3527d97aac
commit
c71134c4ab
@ -126,6 +126,13 @@ void CEXIETHERNET::BuiltInBBAInterface::WriteToQueue(const std::vector<u8>& data
|
|||||||
const u8 next_write_index = (m_queue_write + 1) & 15;
|
const u8 next_write_index = (m_queue_write + 1) & 15;
|
||||||
if (next_write_index != m_queue_read)
|
if (next_write_index != m_queue_read)
|
||||||
m_queue_write = next_write_index;
|
m_queue_write = next_write_index;
|
||||||
|
else
|
||||||
|
WARN_LOG_FMT(SP1, "BBA queue overrun, data might be lost");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CEXIETHERNET::BuiltInBBAInterface::WillQueueOverrun() const
|
||||||
|
{
|
||||||
|
return ((m_queue_write + 1) & 15) == m_queue_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEXIETHERNET::BuiltInBBAInterface::PollData(std::size_t* datasize)
|
void CEXIETHERNET::BuiltInBBAInterface::PollData(std::size_t* datasize)
|
||||||
@ -140,12 +147,13 @@ void CEXIETHERNET::BuiltInBBAInterface::PollData(std::size_t* datasize)
|
|||||||
{
|
{
|
||||||
for (auto& tcp_buf : net_ref.tcp_buffers)
|
for (auto& tcp_buf : net_ref.tcp_buffers)
|
||||||
{
|
{
|
||||||
|
if (WillQueueOverrun())
|
||||||
|
break;
|
||||||
if (!tcp_buf.used || (GetTickCountStd() - tcp_buf.tick) <= 1000)
|
if (!tcp_buf.used || (GetTickCountStd() - tcp_buf.tick) <= 1000)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tcp_buf.tick = GetTickCountStd();
|
|
||||||
// Timed out packet, resend
|
// Timed out packet, resend
|
||||||
if (((m_queue_write + 1) & 15) != m_queue_read)
|
tcp_buf.tick = GetTickCountStd();
|
||||||
WriteToQueue(tcp_buf.data);
|
WriteToQueue(tcp_buf.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
bool WillQueueOverrun() const;
|
||||||
void PollData(std::size_t* datasize);
|
void PollData(std::size_t* datasize);
|
||||||
std::optional<std::vector<u8>> TryGetDataFromSocket(StackRef* ref);
|
std::optional<std::vector<u8>> TryGetDataFromSocket(StackRef* ref);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user