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.0.6.5-rc1
parent
594c7c3eb1
commit
f31a60bad7
|
@ -96,6 +96,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
internal int depends = 0;
|
||||
|
||||
// This variable counts the number of resets that have been performed
|
||||
// on the connector. When a listener thread terminates, it checks to
|
||||
// see of the reset count has changed before it schedules another
|
||||
// reset.
|
||||
|
||||
internal int m_resetk = 0;
|
||||
|
||||
// Working threads
|
||||
|
||||
private Thread m_listener = null;
|
||||
|
@ -229,7 +236,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
// Add the newly created connector to the known connectors list
|
||||
|
||||
m_connectors.Add(this);
|
||||
// m_connectors.Add(this);
|
||||
|
||||
m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn);
|
||||
|
||||
|
@ -393,6 +400,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
if (m_connected)
|
||||
{
|
||||
|
||||
m_log.InfoFormat("[IRC-Connector-{0}] Resetting connector", idn);
|
||||
|
||||
// Mark as disconnected. This will allow the listener thread
|
||||
|
@ -410,6 +418,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
m_connected = false;
|
||||
m_pending = false;
|
||||
m_resetk++;
|
||||
|
||||
}
|
||||
|
||||
|
@ -478,7 +487,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
public void ListenerRun()
|
||||
{
|
||||
|
||||
string inputLine;
|
||||
int resetk = m_resetk;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -534,7 +545,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
// The connection is marked as not connected the first time
|
||||
// through reconnect.
|
||||
|
||||
if (m_enabled) Reconnect();
|
||||
if (m_enabled && (m_resetk == resetk))
|
||||
Reconnect();
|
||||
|
||||
}
|
||||
|
||||
|
@ -830,6 +842,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
|
||||
foreach (IRCConnector connector in m_connectors)
|
||||
{
|
||||
// m_log.InfoFormat("[IRC-Watchdog] Scanning {0}", connector);
|
||||
if (connector.Enabled)
|
||||
{
|
||||
if (!connector.Connected)
|
||||
|
@ -851,7 +864,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
{
|
||||
if (connector.m_timeout == 0)
|
||||
{
|
||||
m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn);
|
||||
// m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn);
|
||||
connector.Reconnect();
|
||||
}
|
||||
else
|
||||
|
@ -865,10 +878,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
|
|||
connector.m_writer.WriteLine(String.Format("PING :{0}", connector.m_server));
|
||||
connector.m_writer.Flush();
|
||||
}
|
||||
catch (Exception /*e*/)
|
||||
catch (Exception e)
|
||||
{
|
||||
// m_log.ErrorFormat("[IRC-PingRun] Exception on connector {0}: {1} ", connector.idn, e.Message);
|
||||
// m_log.Debug(e);
|
||||
m_log.ErrorFormat("[IRC-PingRun] Exception on connector {0}: {1} ", connector.idn, e.Message);
|
||||
m_log.Debug(e);
|
||||
connector.Reconnect();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue