aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDr Scofield2009-04-21 13:17:34 +0000
committerDr Scofield2009-04-21 13:17:34 +0000
commitf31a60bad7133f877fe50570d811b320905280ab (patch)
treeb3d64380d1c85079058bc4267c4242ae3880d4de /OpenSim
parent* Implements Extensions to MRM. This allows Region Modules to insert new clas... (diff)
downloadopensim-SC_OLD-f31a60bad7133f877fe50570d811b320905280ab.zip
opensim-SC_OLD-f31a60bad7133f877fe50570d811b320905280ab.tar.gz
opensim-SC_OLD-f31a60bad7133f877fe50570d811b320905280ab.tar.bz2
opensim-SC_OLD-f31a60bad7133f877fe50570d811b320905280ab.tar.xz
From: Alan Webb <alan_webb@us.ibm.com>
Fixes IRC reconnect problem When a session fails to establish, the login attempt eventually times out and the login is retried. This should occur once every 25 seconds (to give the server plenty of time to respond). In fact the interval was typically only 10 seconds, this was being caused by a second reset that was being scheduled when the failed listener thread was terminated. Because the second reset occurred inside the ICC timeout, it eventually gets scheduled after only 10 seconds. In addition to this, the connector was being added to the monitoring twice. This was harmless, but entirely redundant. Both of these problems have been fixed and tested. Each connector now maintains a count of how often it has been reset. The listener thread records this value on entry and checks for a change on exit. If the counts are the same, then the listener is exiting and can potentially reschedule the connection.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs25
1 files changed, 19 insertions, 6 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
index 5123ef5..ca85817 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
@@ -96,6 +96,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
96 96
97 internal int depends = 0; 97 internal int depends = 0;
98 98
99 // This variable counts the number of resets that have been performed
100 // on the connector. When a listener thread terminates, it checks to
101 // see of the reset count has changed before it schedules another
102 // reset.
103
104 internal int m_resetk = 0;
105
99 // Working threads 106 // Working threads
100 107
101 private Thread m_listener = null; 108 private Thread m_listener = null;
@@ -229,7 +236,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
229 236
230 // Add the newly created connector to the known connectors list 237 // Add the newly created connector to the known connectors list
231 238
232 m_connectors.Add(this); 239 // m_connectors.Add(this);
233 240
234 m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn); 241 m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn);
235 242
@@ -393,6 +400,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
393 400
394 if (m_connected) 401 if (m_connected)
395 { 402 {
403
396 m_log.InfoFormat("[IRC-Connector-{0}] Resetting connector", idn); 404 m_log.InfoFormat("[IRC-Connector-{0}] Resetting connector", idn);
397 405
398 // Mark as disconnected. This will allow the listener thread 406 // Mark as disconnected. This will allow the listener thread
@@ -410,6 +418,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
410 418
411 m_connected = false; 419 m_connected = false;
412 m_pending = false; 420 m_pending = false;
421 m_resetk++;
413 422
414 } 423 }
415 424
@@ -478,7 +487,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
478 487
479 public void ListenerRun() 488 public void ListenerRun()
480 { 489 {
490
481 string inputLine; 491 string inputLine;
492 int resetk = m_resetk;
482 493
483 try 494 try
484 { 495 {
@@ -534,7 +545,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
534 // The connection is marked as not connected the first time 545 // The connection is marked as not connected the first time
535 // through reconnect. 546 // through reconnect.
536 547
537 if (m_enabled) Reconnect(); 548 if (m_enabled && (m_resetk == resetk))
549 Reconnect();
538 550
539 } 551 }
540 552
@@ -830,6 +842,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
830 842
831 foreach (IRCConnector connector in m_connectors) 843 foreach (IRCConnector connector in m_connectors)
832 { 844 {
845 // m_log.InfoFormat("[IRC-Watchdog] Scanning {0}", connector);
833 if (connector.Enabled) 846 if (connector.Enabled)
834 { 847 {
835 if (!connector.Connected) 848 if (!connector.Connected)
@@ -851,7 +864,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
851 { 864 {
852 if (connector.m_timeout == 0) 865 if (connector.m_timeout == 0)
853 { 866 {
854 m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn); 867 // m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn);
855 connector.Reconnect(); 868 connector.Reconnect();
856 } 869 }
857 else 870 else
@@ -865,10 +878,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
865 connector.m_writer.WriteLine(String.Format("PING :{0}", connector.m_server)); 878 connector.m_writer.WriteLine(String.Format("PING :{0}", connector.m_server));
866 connector.m_writer.Flush(); 879 connector.m_writer.Flush();
867 } 880 }
868 catch (Exception /*e*/) 881 catch (Exception e)
869 { 882 {
870 // m_log.ErrorFormat("[IRC-PingRun] Exception on connector {0}: {1} ", connector.idn, e.Message); 883 m_log.ErrorFormat("[IRC-PingRun] Exception on connector {0}: {1} ", connector.idn, e.Message);
871 // m_log.Debug(e); 884 m_log.Debug(e);
872 connector.Reconnect(); 885 connector.Reconnect();
873 } 886 }
874 } 887 }