]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Only join threads if we were active
authorMatthew Endsley <mendsley@gmail.com>
Tue, 2 Feb 2021 15:07:52 +0000 (07:07 -0800)
committerMatthew Endsley <mendsley@gmail.com>
Tue, 2 Feb 2021 17:30:38 +0000 (09:30 -0800)
Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs

index 7e2da604af30aa1920123b6eb9c6588c4691b4eb..98f83011bb9bfa2990e4cf0865e3b7f19c21cc9e 100644 (file)
@@ -359,15 +359,19 @@ namespace Hazel.Udp.FewerThreads
             try { this.socket.Close(); } catch { }
             try { this.socket.Dispose(); } catch { }
 
+            bool wasActive = this.isActive;
             this.isActive = false;
 
             this.receiveQueue?.CompleteAdding();
             this.sendQueue?.CompleteAdding();
 
-            this.reliablePacketThread.Join();
-            this.sendThread.Join();
-            this.receiveThread.Join();
-            this.processThreads.Join();
+            if (wasActive)
+            {
+                this.reliablePacketThread.Join();
+                this.sendThread.Join();
+                this.receiveThread.Join();
+                this.processThreads.Join();
+            }
 
             this.receiveQueue?.Dispose();
             this.receiveQueue = null;