diff options
author | Dr Scofield | 2009-04-23 09:06:36 +0000 |
---|---|---|
committer | Dr Scofield | 2009-04-23 09:06:36 +0000 |
commit | 4b7a2085592c67d86a57305465208adc482a2203 (patch) | |
tree | bfb2012ccc6d18e0b8a6eed9047150bbc14a6578 /OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs | |
parent | Update svn properties. (diff) | |
download | opensim-SC_OLD-4b7a2085592c67d86a57305465208adc482a2203.zip opensim-SC_OLD-4b7a2085592c67d86a57305465208adc482a2203.tar.gz opensim-SC_OLD-4b7a2085592c67d86a57305465208adc482a2203.tar.bz2 opensim-SC_OLD-4b7a2085592c67d86a57305465208adc482a2203.tar.xz |
From: Alan M Webb <alan_webb@us.ibm.com>
Some other IRC timing wrinkles showed up:
[1] If connect processing blocked in socket activation, then
the watch dog saw the session as connected, and eventually
tried to ping, but because the socket create was still
blocked, it barfed on a null reference. This then drove
reconnect. Changed the watchdog handler so that it only
tries to ping connections that are connected and not pending.
[2] If the socket creation actually fails, then the connect and
pending flags were reset. This resulted in the connection
being retried at the earliest possible opportunity. The
longer login-timeout is preferrable, so the status flags
are not reset, and the failed login is eventually timed
out.
[3] The Inter-connection interval is primed so that the first
session can connect without delay.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs index c621fd3..eb6634d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs | |||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
61 | 61 | ||
62 | private static int _idk_ = 0; // core connector identifier | 62 | private static int _idk_ = 0; // core connector identifier |
63 | private static int _pdk_ = 0; // ping interval counter | 63 | private static int _pdk_ = 0; // ping interval counter |
64 | private static int _icc_ = 0; // IRC connect counter | 64 | private static int _icc_ = ICCD_PERIOD; // IRC connect counter |
65 | 65 | ||
66 | // List of configured connectors | 66 | // List of configured connectors |
67 | 67 | ||
@@ -71,6 +71,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
71 | 71 | ||
72 | private static System.Timers.Timer m_watchdog = null; | 72 | private static System.Timers.Timer m_watchdog = null; |
73 | 73 | ||
74 | // The watch-dog gets started as soon as the class is instantiated, and | ||
75 | // ticks once every second (WD_INTERVAL) | ||
76 | |||
74 | static IRCConnector() | 77 | static IRCConnector() |
75 | { | 78 | { |
76 | m_log.DebugFormat("[IRC-Connector]: Static initialization started"); | 79 | m_log.DebugFormat("[IRC-Connector]: Static initialization started"); |
@@ -234,10 +237,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
234 | m_nick = m_baseNick + Util.RandomClass.Next(1, 99); | 237 | m_nick = m_baseNick + Util.RandomClass.Next(1, 99); |
235 | } | 238 | } |
236 | 239 | ||
237 | // Add the newly created connector to the known connectors list | ||
238 | |||
239 | // m_connectors.Add(this); | ||
240 | |||
241 | m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn); | 240 | m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn); |
242 | 241 | ||
243 | } | 242 | } |
@@ -255,14 +254,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
255 | if (!m_enabled) | 254 | if (!m_enabled) |
256 | { | 255 | { |
257 | 256 | ||
258 | m_connectors.Add(this); | ||
259 | m_enabled = true; | ||
260 | |||
261 | if (!Connected) | 257 | if (!Connected) |
262 | { | 258 | { |
263 | Connect(); | 259 | Connect(); |
264 | } | 260 | } |
265 | 261 | ||
262 | lock(m_connectors) | ||
263 | m_connectors.Add(this); | ||
264 | |||
265 | m_enabled = true; | ||
266 | |||
266 | } | 267 | } |
267 | } | 268 | } |
268 | 269 | ||
@@ -305,7 +306,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
305 | 306 | ||
306 | } | 307 | } |
307 | 308 | ||
308 | m_connectors.Remove(this); | 309 | lock(m_connectors) |
310 | m_connectors.Remove(this); | ||
309 | 311 | ||
310 | } | 312 | } |
311 | } | 313 | } |
@@ -340,6 +342,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
340 | 342 | ||
341 | try | 343 | try |
342 | { | 344 | { |
345 | |||
343 | if (m_connected) return; | 346 | if (m_connected) return; |
344 | 347 | ||
345 | m_connected = true; | 348 | m_connected = true; |
@@ -376,8 +379,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
376 | { | 379 | { |
377 | m_log.ErrorFormat("[IRC-Connector-{0}] cannot connect {1} to {2}:{3}: {4}", | 380 | m_log.ErrorFormat("[IRC-Connector-{0}] cannot connect {1} to {2}:{3}: {4}", |
378 | idn, m_nick, m_server, m_port, e.Message); | 381 | idn, m_nick, m_server, m_port, e.Message); |
379 | m_connected = false; | 382 | // It might seem reasonable to reset connected and pending status here |
380 | m_pending = false; | 383 | // Seeing as we know that the login has failed, but if we do that, then |
384 | // connection will be retried each time the interconnection interval | ||
385 | // expires. By leaving them as they are, the connection will be retried | ||
386 | // when the login timeout expires. Which is preferred. | ||
381 | } | 387 | } |
382 | 388 | ||
383 | } | 389 | } |
@@ -834,14 +840,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
834 | protected static void WatchdogHandler(Object source, ElapsedEventArgs args) | 840 | protected static void WatchdogHandler(Object source, ElapsedEventArgs args) |
835 | { | 841 | { |
836 | 842 | ||
837 | // m_log.InfoFormat("[IRC-Watchdog] Status scan"); | 843 | // m_log.InfoFormat("[IRC-Watchdog] Status scan, pdk = {0}, icc = {1}", _pdk_, _icc_); |
838 | 844 | ||
839 | _pdk_ = (_pdk_+1)%PING_PERIOD; // cycle the ping trigger | 845 | _pdk_ = (_pdk_+1)%PING_PERIOD; // cycle the ping trigger |
840 | _icc_++; // increment the inter-consecutive-connect-delay counter | 846 | _icc_++; // increment the inter-consecutive-connect-delay counter |
841 | 847 | ||
848 | lock(m_connectors) | ||
842 | foreach (IRCConnector connector in m_connectors) | 849 | foreach (IRCConnector connector in m_connectors) |
843 | { | 850 | { |
851 | |||
844 | // m_log.InfoFormat("[IRC-Watchdog] Scanning {0}", connector); | 852 | // m_log.InfoFormat("[IRC-Watchdog] Scanning {0}", connector); |
853 | |||
845 | if (connector.Enabled) | 854 | if (connector.Enabled) |
846 | { | 855 | { |
847 | if (!connector.Connected) | 856 | if (!connector.Connected) |
@@ -863,14 +872,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
863 | { | 872 | { |
864 | if (connector.m_timeout == 0) | 873 | if (connector.m_timeout == 0) |
865 | { | 874 | { |
866 | // m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn); | 875 | m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn); |
867 | connector.Reconnect(); | 876 | connector.Reconnect(); |
868 | } | 877 | } |
869 | else | 878 | else |
870 | connector.m_timeout--; | 879 | connector.m_timeout--; |
871 | } | 880 | } |
872 | 881 | ||
873 | if (_pdk_ == 0) | 882 | // Being marked connected is not enough to ping. Socket establishment can sometimes take a long |
883 | // time, in which case the watch dog might try to ping the server before the socket has been | ||
884 | // set up, with nasty side-effects. | ||
885 | |||
886 | else if (_pdk_ == 0) | ||
874 | { | 887 | { |
875 | try | 888 | try |
876 | { | 889 | { |