Skip to content

Commit

Permalink
fix: Telepathy fix a bug where calling Disconnect while connecting to…
Browse files Browse the repository at this point in the history
… a dead end would freeze Unity because .Join would wait forever. Interrupt fixes it.
  • Loading branch information
miwarnec committed Sep 30, 2019
1 parent cec9667 commit 3831cbd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Assets/Mirror/Runtime/Transport/Telepathy/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ public void Disconnect()

// wait until thread finished. this is the only way to guarantee
// that we can call Connect() again immediately after Disconnect
receiveThread?.Join();
// -> calling .Join would sometimes wait forever, e.g. when
// calling Disconnect while trying to connect to a dead end
receiveThread?.Interrupt();

// we interrupted the receive Thread, so we can't guarantee that
// connecting was reset. let's do it manually.
_Connecting = false;

// clear send queues. no need to hold on to them.
// (unlike receiveQueue, which is still needed to process the
Expand Down

0 comments on commit 3831cbd

Please sign in to comment.