mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #475 from east/timeoutprotfix
Copy resendbuffer on timeout protection
This commit is contained in:
commit
6c771f6bff
|
@ -220,7 +220,9 @@ public:
|
|||
int AckSequence() const { return m_Ack; }
|
||||
int SeqSequence() const { return m_Sequence; }
|
||||
int SecurityToken() const { return m_SecurityToken; }
|
||||
void SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken);
|
||||
TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> *ResendBuffer() { return &m_Buffer; };
|
||||
|
||||
void SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken, TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> *pResendBuffer);
|
||||
|
||||
// anti spoof
|
||||
void DirectInit(NETADDR &Addr, SECURITY_TOKEN SecurityToken);
|
||||
|
|
|
@ -467,7 +467,7 @@ int CNetConnection::Update()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken)
|
||||
void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SECURITY_TOKEN SecurityToken, TStaticRingBuffer<CNetChunkResend, NET_CONN_BUFFERSIZE> *pResendBuffer)
|
||||
{
|
||||
int64 Now = time_get();
|
||||
|
||||
|
@ -482,5 +482,16 @@ void CNetConnection::SetTimedOut(const NETADDR *pAddr, int Sequence, int Ack, SE
|
|||
m_LastRecvTime = Now;
|
||||
m_LastUpdateTime = Now;
|
||||
m_SecurityToken = SecurityToken;
|
||||
|
||||
// copy resend buffer
|
||||
m_Buffer.Init();
|
||||
while (pResendBuffer->First())
|
||||
{
|
||||
CNetChunkResend *First = pResendBuffer->First();
|
||||
|
||||
CNetChunkResend *pResend = m_Buffer.Allocate(sizeof(CNetChunkResend)+First->m_DataSize);
|
||||
mem_copy(pResend, First, sizeof(CNetChunkResend)+First->m_DataSize);
|
||||
|
||||
pResendBuffer->PopFirst();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -684,7 +684,7 @@ bool CNetServer::SetTimedOut(int ClientID, int OrigID)
|
|||
if (m_aSlots[ClientID].m_Connection.State() != NET_CONNSTATE_ERROR)
|
||||
return false;
|
||||
|
||||
m_aSlots[ClientID].m_Connection.SetTimedOut(ClientAddr(OrigID), m_aSlots[OrigID].m_Connection.SeqSequence(), m_aSlots[OrigID].m_Connection.AckSequence(), m_aSlots[OrigID].m_Connection.SecurityToken());
|
||||
m_aSlots[ClientID].m_Connection.SetTimedOut(ClientAddr(OrigID), m_aSlots[OrigID].m_Connection.SeqSequence(), m_aSlots[OrigID].m_Connection.AckSequence(), m_aSlots[OrigID].m_Connection.SecurityToken(), m_aSlots[OrigID].m_Connection.ResendBuffer());
|
||||
m_aSlots[OrigID].m_Connection.Reset();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue