1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-06 02:11:06 +09:00

Fixed issue with recycling count and resent messages

This commit is contained in:
Michael Lidgren
2015-02-06 19:23:32 +01:00
parent b3fffb52e5
commit 6a0abf25c3
3 changed files with 16 additions and 6 deletions

View File

@@ -187,10 +187,14 @@ namespace Lidgren.Network
{
if (m_outgoingMessagesPool == null)
return;
NetException.Assert(msg.m_recyclingCount == 0, "Wrong recycling count! Should be zero; found " + msg.m_recyclingCount);
#if DEBUG
NetException.Assert(m_outgoingMessagesPool.Contains(msg) == false, "Recyling already recycled message! Thread race?");
if (msg.m_recyclingCount != 0)
LogWarning("Wrong recycling count! should be zero; found " + msg.m_recyclingCount);
#endif
// setting m_recyclingCount to zero SHOULD be an unnecessary maneuver, if it's not zero something is wrong
// however, in RELEASE, we'll just have to accept this and move on with life
msg.m_recyclingCount = 0;
byte[] storage = msg.m_data;
msg.m_data = null;

View File

@@ -220,7 +220,10 @@ namespace Lidgren.Network
msg.m_isSent = true;
if (m_configuration.IsMessageTypeEnabled(NetIncomingMessageType.UnconnectedData) == false)
{
Interlocked.Decrement(ref msg.m_recyclingCount);
return; // dropping unconnected message since it's not enabled for receiving
}
NetIncomingMessage om = CreateIncomingMessage(NetIncomingMessageType.UnconnectedData, msg.LengthBytes);
om.Write(msg);

View File

@@ -66,11 +66,12 @@ namespace Lidgren.Network
//
for (int i = 0; i < m_storedMessages.Length; i++)
{
NetOutgoingMessage om = m_storedMessages[i].Message;
var storedMsg = m_storedMessages[i];
NetOutgoingMessage om = storedMsg.Message;
if (om == null)
continue;
double t = m_storedMessages[i].LastSent;
double t = storedMsg.LastSent;
if (t > 0 && (now - t) > m_resendDelay)
{
// deduce sequence number
@@ -89,7 +90,8 @@ namespace Lidgren.Network
//m_connection.m_peer.LogVerbose("Resending due to delay #" + m_storedMessages[i].SequenceNumber + " " + om.ToString());
m_connection.m_statistics.MessageResent(MessageResendReason.Delay);
m_connection.QueueSendMessage(om, m_storedMessages[i].SequenceNumber);
Interlocked.Increment(ref om.m_recyclingCount); // increment this since it's being decremented in QueueSendMessage
m_connection.QueueSendMessage(om, storedMsg.SequenceNumber);
m_storedMessages[i].LastSent = now;
m_storedMessages[i].NumSent++;
@@ -247,6 +249,7 @@ namespace Lidgren.Network
m_storedMessages[slot].LastSent = now;
m_storedMessages[slot].NumSent++;
m_connection.m_statistics.MessageResent(MessageResendReason.HoleInSequence);
Interlocked.Increment(ref rmsg.m_recyclingCount); // increment this since it's being decremented in QueueSendMessage
m_connection.QueueSendMessage(rmsg, rnr);
}
}