]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Acquire lock when resending DTLS packets
authorMatthew Endsley <mendsley@gmail.com>
Wed, 3 Feb 2021 11:38:34 +0000 (03:38 -0800)
committerMatthew Endsley <mendsley@gmail.com>
Wed, 3 Feb 2021 22:40:58 +0000 (14:40 -0800)
Hazel/Dtls/DtlsUnityConnection.cs

index 9800c8802dbbe922314a70bc875c37265504409c..79af8fd999520f15ef793faa03a19427877802e6 100644 (file)
@@ -208,29 +208,32 @@ namespace Hazel.Dtls
         /// <inheritdoc />
         protected override void ResendPacketsIfNeeded()
         {
-            // Check if we need to resend handshake message
-            if (this.nextEpoch.State != HandshakeState.Established)
+            lock (this.syncRoot)
             {
-                DateTime now = DateTime.UtcNow;
-                if (now >= this.nextEpoch.NextPacketResendTime)
+                // Check if we need to resend handshake message
+                if (this.nextEpoch.State != HandshakeState.Established)
                 {
-                    switch (this.nextEpoch.State)
+                    DateTime now = DateTime.UtcNow;
+                    if (now >= this.nextEpoch.NextPacketResendTime)
                     {
-                        case HandshakeState.ExpectingServerHello:
-                        case HandshakeState.ExpectingCertificate:
-                        case HandshakeState.ExpectingServerKeyExchange:
-                        case HandshakeState.ExpectingServerHelloDone:
-                            this.SendClientHello();
-                            break;
+                        switch (this.nextEpoch.State)
+                        {
+                            case HandshakeState.ExpectingServerHello:
+                            case HandshakeState.ExpectingCertificate:
+                            case HandshakeState.ExpectingServerKeyExchange:
+                            case HandshakeState.ExpectingServerHelloDone:
+                                this.SendClientHello();
+                                break;
 
-                        case HandshakeState.ExpectingChangeCipherSpec:
-                        case HandshakeState.ExpectingFinished:
-                            this.SendClientKeyExchangeFlight(true);
-                            break;
+                            case HandshakeState.ExpectingChangeCipherSpec:
+                            case HandshakeState.ExpectingFinished:
+                                this.SendClientKeyExchangeFlight(true);
+                                break;
 
-                        case HandshakeState.Established:
-                        default:
-                            break;
+                            case HandshakeState.Established:
+                            default:
+                                break;
+                        }
                     }
                 }
             }