]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Added aknowledged flag
authorJamJar00 <jamster.30@btinternet.com>
Thu, 12 May 2016 21:08:01 +0000 (22:08 +0100)
committerJamJar00 <jamster.30@btinternet.com>
Thu, 12 May 2016 21:08:01 +0000 (22:08 +0100)
Hazel/UdpConnection.Reliable.cs

index fd53ab749741a958bd6f2da9b90f0768fa31ea90..d69b3935322cc971e847af4e48e02f0ad7a701cd 100644 (file)
@@ -56,8 +56,9 @@ namespace Hazel
         {
             public byte[] Data;
             public Timer Timer;
-            public int LastTimeout;
+            public volatile int LastTimeout;
             public Action AckCallback;
+            public volatile bool Acknowledged = false;
 
             public Packet(byte[] data, Action<Packet> resendAction, int timeout, Action ackCallback)
             {
@@ -103,7 +104,10 @@ namespace Hazel
 
                         //Double packet timeout
                         lock (p.Timer)
-                            p.Timer.Change(p.LastTimeout *= 2, Timeout.Infinite);
+                        {
+                            if (!p.Acknowledged)
+                                p.Timer.Change(p.LastTimeout *= 2, Timeout.Infinite);
+                        }
 
                         Trace.WriteLine("Resend.");
                     },
@@ -176,6 +180,8 @@ namespace Hazel
                 {
                     Packet packet = reliableDataPacketsSent[id];
                     
+                    packet.Acknowledged = true;
+
                     lock (packet.Timer)
                         packet.Timer.Dispose();