From cbf4106987b3be2fd1c5b3d3a8b3ddb5c18bd488 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 4 Sep 2014 00:00:51 +0100 Subject: [PATCH] Start long-lived thread in IRCConnector via watchdog rather than indepedently, so that it can be seen in "show threads" and stats --- .../Avatar/Chat/IRCConnector.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs index f5bd44db5f..bdd07e0a99 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs @@ -109,10 +109,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat internal int m_resetk = 0; - // Working threads - - private Thread m_listener = null; - private Object msyncConnect = new Object(); internal bool m_randomizeNick = true; // add random suffix @@ -363,10 +359,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat m_log.InfoFormat("[IRC-Connector-{0}]: Connected to {1}:{2}", idn, m_server, m_port); - m_listener = new Thread(new ThreadStart(ListenerRun)); - m_listener.Name = "IRCConnectorListenerThread"; - m_listener.IsBackground = true; - m_listener.Start(); + Watchdog.StartThread(ListenerRun, "IRCConnectionListenerThread", ThreadPriority.Normal, true, false); // This is the message order recommended by RFC 2812 if (m_password != null) @@ -510,21 +503,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat { while (m_enabled && m_connected) { - if ((inputLine = m_reader.ReadLine()) == null) throw new Exception("Listener input socket closed"); + Watchdog.UpdateThread(); + // m_log.Info("[IRCConnector]: " + inputLine); if (inputLine.Contains("PRIVMSG")) { - Dictionary data = ExtractMsg(inputLine); // Any chat ??? if (data != null) { - OSChatMessage c = new OSChatMessage(); c.Message = data["msg"]; c.Type = ChatTypeEnum.Region; @@ -540,9 +532,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat c.Message = String.Format("/me {0}", c.Message.Substring(8, c.Message.Length - 9)); ChannelState.OSChat(this, c, false); - } - } else { @@ -562,6 +552,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat if (m_enabled && (m_resetk == resetk)) Reconnect(); + + Watchdog.RemoveThread(); } private Regex RE = new Regex(@":(?[\w-]*)!(?\S*) PRIVMSG (?\S+) :(?.*)",