From 8106ecbf4e300e79ede54d1bd6f86cd5f01624b9 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sun, 1 Nov 2015 22:08:07 +0000 Subject: [PATCH] Work around a hang on shutdown caused by IRC. Our IRC client doesn't shut down properly - but we only need to shut it down when we're about to close the game anyway, so we just don't bother since it won't hurt anybody. --- OpenRA.Game/GlobalChat.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/GlobalChat.cs b/OpenRA.Game/GlobalChat.cs index 59e7ad5b46..6ad2faf6c9 100644 --- a/OpenRA.Game/GlobalChat.cs +++ b/OpenRA.Game/GlobalChat.cs @@ -150,7 +150,7 @@ namespace OpenRA.Chat } client.Listen(); - }) { Name = "IrcListenThread" }.Start(); + }) { Name = "IrcListenThread", IsBackground = true }.Start(); } void AddNotification(string text) @@ -364,8 +364,19 @@ namespace OpenRA.Chat public void Dispose() { - if (client.IsConnected) - client.Disconnect(); + // HACK: The IRC library we are using has terrible thread-handling code that relies on Thread.Abort. + // There is a thread reading from the network socket which is aborted, however on Windows this is inside + // native code so this abort call hangs until the network socket reads something and returns to managed + // code where it can then be aborted. + // + // This means we may hang for several seconds during shutdown (until we receive something over IRC!) before + // closing. + // + // Since our IRC client currently lives forever, the only time we call this Dispose method is during the + // shutdown of our process. Therefore, we can work around the problem by just not bothering to disconnect + // properly. Since our process is about to die anyway, it's not like anyone will care. + ////if (client.IsConnected) + //// client.Disconnect(); } } } \ No newline at end of file