aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorDr Scofield2008-11-14 10:50:36 +0000
committerDr Scofield2008-11-14 10:50:36 +0000
commit62317ded9f7e426851591dd723a15b78fd0f9012 (patch)
tree8d039bfe8603ce2c049a8f26f44fa121ab372afe /OpenSim/Region/Environment
parentSome changes to the money module to allow a more flexible system of (diff)
downloadopensim-SC_OLD-62317ded9f7e426851591dd723a15b78fd0f9012.zip
opensim-SC_OLD-62317ded9f7e426851591dd723a15b78fd0f9012.tar.gz
opensim-SC_OLD-62317ded9f7e426851591dd723a15b78fd0f9012.tar.bz2
opensim-SC_OLD-62317ded9f7e426851591dd723a15b78fd0f9012.tar.xz
From: Alan Webb (alan_webb@us.ibm.com)
Fixed the IRC code so that it deals with regions coming and going.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs85
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs82
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs68
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/RegionState.cs4
4 files changed, 129 insertions, 110 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs
index 6265698..213ae96 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs
@@ -256,20 +256,25 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
256 // values that, while independent of the IRC connetion, do still distinguish 256 // values that, while independent of the IRC connetion, do still distinguish
257 // this region's behavior. 257 // this region's behavior.
258 258
259 foreach (ChannelState xcs in IRCBridgeModule.m_channels) 259 lock (IRCBridgeModule.m_channels)
260 { 260 {
261 if (cs.IsAPerfectMatchFor(xcs)) 261
262 { 262 foreach (ChannelState xcs in IRCBridgeModule.m_channels)
263 m_log.DebugFormat("[IRC-Channel-{0}] Channel state matched", cs.idn);
264 cs = xcs;
265 break;
266 }
267 if (cs.IsAConnectionMatchFor(xcs))
268 { 263 {
269 m_log.DebugFormat("[IRC-Channel-{0}] Channel matched", cs.idn); 264 if (cs.IsAPerfectMatchFor(xcs))
270 cs.irc = xcs.irc; 265 {
271 break; 266 m_log.DebugFormat("[IRC-Channel-{0}] Channel state matched", cs.idn);
267 cs = xcs;
268 break;
269 }
270 if (cs.IsAConnectionMatchFor(xcs))
271 {
272 m_log.DebugFormat("[IRC-Channel-{0}] Channel matched", cs.idn);
273 cs.irc = xcs.irc;
274 break;
275 }
272 } 276 }
277
273 } 278 }
274 279
275 // No entry was found, so this is going to be a new entry. 280 // No entry was found, so this is going to be a new entry.
@@ -281,6 +286,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
281 286
282 if ((cs.irc = new IRCConnector(cs)) != null) 287 if ((cs.irc = new IRCConnector(cs)) != null)
283 { 288 {
289
284 IRCBridgeModule.m_channels.Add(cs); 290 IRCBridgeModule.m_channels.Add(cs);
285 291
286 m_log.InfoFormat("[IRC-Channel-{0}] New channel initialized for {1}, nick: {2}, commands {3}, private channels {4}", 292 m_log.InfoFormat("[IRC-Channel-{0}] New channel initialized for {1}, nick: {2}, commands {3}, private channels {4}",
@@ -302,11 +308,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
302 cs.idn, rs.Region, cs.IrcChannel, cs.Server, cs.Port); 308 cs.idn, rs.Region, cs.IrcChannel, cs.Server, cs.Port);
303 } 309 }
304 310
305 m_log.InfoFormat("[IRC-Channel-{0}] Region {1} connected to channel {2} on server {3}:{4}", 311 m_log.InfoFormat("[IRC-Channel-{0}] Region {1} associated with channel {2} on server {3}:{4}",
306 cs.idn, rs.Region, cs.IrcChannel, cs.Server, cs.Port); 312 cs.idn, rs.Region, cs.IrcChannel, cs.Server, cs.Port);
307 313
308 // We're finally ready to commit ourselves 314 // We're finally ready to commit ourselves
309 315
316
310 return cs; 317 return cs;
311 318
312 } 319 }
@@ -443,6 +450,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
443 // Repeatedly scan the string until all possible 450 // Repeatedly scan the string until all possible
444 // substitutions have been performed. 451 // substitutions have been performed.
445 452
453 // m_log.DebugFormat("[IRC-Channel] Parse[1]: {0}", result);
454
446 while (arg.IsMatch(result)) 455 while (arg.IsMatch(result))
447 { 456 {
448 457
@@ -476,28 +485,26 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
476 result = result.Replace(vvar, rs.config.GetString(var,var)); 485 result = result.Replace(vvar, rs.config.GetString(var,var));
477 break; 486 break;
478 } 487 }
488 // m_log.DebugFormat("[IRC-Channel] Parse[2]: {0}", result);
479 } 489 }
480 490
491 // m_log.DebugFormat("[IRC-Channel] Parse[3]: {0}", result);
481 return result; 492 return result;
482 493
483 } 494 }
484 495
485 public void Close() 496 public void Close()
486 { 497 {
487 498 m_log.InfoFormat("[IRC-Channel-{0}] Closing channel <{1}> to server <{2}:{3}>",
488 m_log.InfoFormat("[IRC-Channel-{0}] Closing channel <{1} to server <{2}:{3}>",
489 idn, IrcChannel, Server, Port); 499 idn, IrcChannel, Server, Port);
490
491 m_log.InfoFormat("[IRC-Channel-{0}] There are {1} active clients", 500 m_log.InfoFormat("[IRC-Channel-{0}] There are {1} active clients",
492 idn, clientregions.Count); 501 idn, clientregions.Count);
493
494 irc.Close(); 502 irc.Close();
495
496 } 503 }
497 504
498 public void Open() 505 public void Open()
499 { 506 {
500 m_log.InfoFormat("[IRC-Channel-{0}] Opening channel <{1} to server <{2}:{3}>", 507 m_log.InfoFormat("[IRC-Channel-{0}] Opening channel <{1}> to server <{2}:{3}>",
501 idn, IrcChannel, Server, Port); 508 idn, IrcChannel, Server, Port);
502 509
503 irc.Open(); 510 irc.Open();
@@ -514,16 +521,30 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
514 Open(); 521 Open();
515 } 522 }
516 523
524 // Close is called to ensure that the IRC session is terminated if this is the
525 // only client.
526
517 public void Close(RegionState rs) 527 public void Close(RegionState rs)
518 { 528 {
519 RemoveRegion(rs); 529 RemoveRegion(rs);
530 lock (IRCBridgeModule.m_channels)
531 {
532 if (clientregions.Count == 0)
533 {
534 Close();
535 IRCBridgeModule.m_channels.Remove(this);
536 m_log.InfoFormat("[IRC-Channel-{0}] Region {1} is last user of channel <{2}> to server <{3}:{4}>",
537 idn, rs.Region, IrcChannel, Server, Port);
538 m_log.InfoFormat("[IRC-Channel-{0}] Removed", idn);
539 }
540 }
520 } 541 }
521 542
522 // Add a client region to this channel if it is not already known 543 // Add a client region to this channel if it is not already known
523 544
524 public void AddRegion(RegionState rs) 545 public void AddRegion(RegionState rs)
525 { 546 {
526 m_log.InfoFormat("[IRC-Channel-{0}] Adding region {1} to channel <{2} to server <{3}:{4}>", 547 m_log.InfoFormat("[IRC-Channel-{0}] Adding region {1} to channel <{2}> to server <{3}:{4}>",
527 idn, rs.Region, IrcChannel, Server, Port); 548 idn, rs.Region, IrcChannel, Server, Port);
528 if (!clientregions.Contains(rs)) 549 if (!clientregions.Contains(rs))
529 { 550 {
@@ -568,28 +589,30 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
568 // Note that this code is responsible for completing some of the 589 // Note that this code is responsible for completing some of the
569 // settings for the inbound OSChatMessage 590 // settings for the inbound OSChatMessage
570 591
571 foreach (ChannelState cs in IRCBridgeModule.m_channels) 592 lock (IRCBridgeModule.m_channels)
572 { 593 {
573 if ( p_irc == cs.irc) 594 foreach (ChannelState cs in IRCBridgeModule.m_channels)
574 { 595 {
596 if ( p_irc == cs.irc)
597 {
575 598
576 // This non-IRC differentiator moved to here 599 // This non-IRC differentiator moved to here
577 600
578 if (cmsg && !cs.ClientReporting) 601 if (cmsg && !cs.ClientReporting)
579 continue; 602 continue;
580 603
581 // This non-IRC differentiator moved to here 604 // This non-IRC differentiator moved to here
582 605
583 c.Channel = (cs.RelayPrivateChannels ? cs.RelayChannel : 0); 606 c.Channel = (cs.RelayPrivateChannels ? cs.RelayChannel : 0);
584 607
585 foreach (RegionState region in cs.clientregions) 608 foreach (RegionState region in cs.clientregions)
586 { 609 {
587 region.OSChat(cs.irc, c); 610 region.OSChat(cs.irc, c);
588 } 611 }
589 612
613 }
590 } 614 }
591 } 615 }
592
593 } 616 }
594 catch (Exception ex) 617 catch (Exception ex)
595 { 618 {
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
index 47d3265..49c4a06 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
@@ -49,11 +49,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
49 internal static bool enabled = false; 49 internal static bool enabled = false;
50 internal static IConfig m_config = null; 50 internal static IConfig m_config = null;
51 51
52 internal static List<RegionState> m_regions = new List<RegionState>();
53 internal static List<ChannelState> m_channels = new List<ChannelState>(); 52 internal static List<ChannelState> m_channels = new List<ChannelState>();
53 internal static List<RegionState> m_regions = new List<RegionState>();
54 54
55 internal static string password = String.Empty; 55 internal static string password = String.Empty;
56 56
57 internal RegionState region = null;
58
57 #region IRegionModule Members 59 #region IRegionModule Members
58 60
59 public string Name 61 public string Name
@@ -63,7 +65,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
63 65
64 public bool IsSharedModule 66 public bool IsSharedModule
65 { 67 {
66 get { return true; } 68 get { return false; }
67 } 69 }
68 70
69 public void Initialise(Scene scene, IConfigSource config) 71 public void Initialise(Scene scene, IConfigSource config)
@@ -110,13 +112,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
110 // Iff the IRC bridge is enabled, then each new region may be 112 // Iff the IRC bridge is enabled, then each new region may be
111 // connected to IRC. But it should NOT be obligatory (and it 113 // connected to IRC. But it should NOT be obligatory (and it
112 // is not). 114 // is not).
115 // We have to do ALL of the startup here because PostInitialize
116 // is not called when a region gets created in-flight from the
117 // command line.
113 118
114 if (enabled) 119 if (enabled)
115 { 120 {
116 try 121 try
117 { 122 {
118 m_log.InfoFormat("[IRC-Bridge] Connecting region {0}", scene.RegionInfo.RegionName); 123 m_log.InfoFormat("[IRC-Bridge] Connecting region {0}", scene.RegionInfo.RegionName);
119 m_regions.Add(new RegionState(scene, m_config)); 124 region = new RegionState(scene, m_config);
125 lock(m_regions) m_regions.Add(region);
126 region.Open();
120 } 127 }
121 catch (Exception e) 128 catch (Exception e)
122 { 129 {
@@ -131,37 +138,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
131 138
132 } 139 }
133 140
134 // Called after all region modules have been loaded. 141 // This module can be called in-flight in which case PostInitialize
135 // Iff the IRC bridge is enabled, then start all of the 142 // is not called following Initialize. So no use is made of this
136 // configured channels. The set of channels is a side 143 // call.
137 // effect of RegionState creation.
138 144
139 public void PostInitialise() 145 public void PostInitialise()
140 { 146 {
141 147
142 if (!enabled)
143 return;
144
145 foreach (RegionState region in m_regions)
146 {
147 m_log.InfoFormat("[IRC-Bridge] Opening connection for {0}:{1} on IRC server {2}:{3}",
148 region.Region, region.cs.BaseNickname, region.cs.Server, region.cs.IrcChannel);
149 try
150 {
151 region.Open();
152 }
153 catch (Exception e)
154 {
155 m_log.ErrorFormat("[IRC-Bridge] Open failed for {0}:{1} on IRC server {2}:{3} : {4}",
156 region.Region, region.cs.BaseNickname, region.cs.Server, region.cs.IrcChannel,
157 e.Message);
158 }
159 }
160
161 } 148 }
162 149
163 // Called immediately before the region module is unloaded. Close all 150 // Called immediately before the region module is unloaded. Cleanup
164 // associated channels. 151 // the region.
165 152
166 public void Close() 153 public void Close()
167 { 154 {
@@ -169,47 +156,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
169 if (!enabled) 156 if (!enabled)
170 return; 157 return;
171 158
172 // Stop each of the region sessions 159 region.Close();
173 160 lock(m_regions) m_regions.Remove(region);
174 foreach (RegionState region in m_regions)
175 {
176 m_log.InfoFormat("[IRC-Bridge] Closing connection for {0}:{1} on IRC server {2}:{3}",
177 region.Region, region.cs.BaseNickname, region.cs.Server, region.cs.IrcChannel);
178 try
179 {
180 region.Close();
181 }
182 catch (Exception e)
183 {
184 m_log.ErrorFormat("[IRC-Bridge] Close failed for {0}:{1} on IRC server {2}:{3} : {4}",
185 region.Region, region.cs.BaseNickname, region.cs.Server, region.cs.IrcChannel,
186 e.Message);
187 }
188 }
189
190 // Perform final cleanup of the channels (they now have no active clients)
191
192 foreach (ChannelState channel in m_channels)
193 {
194 m_log.InfoFormat("[IRC-Bridge] Closing connection for {0} on IRC server {1}:{2}",
195 channel.BaseNickname, channel.Server, channel.IrcChannel);
196 try
197 {
198 channel.Close();
199 }
200 catch (Exception e)
201 {
202 m_log.ErrorFormat("[IRC-Bridge] Close failed for {0} on IRC server {1}:{2} : {3}",
203 channel.BaseNickname, channel.Server, channel.IrcChannel,
204 e.Message);
205 }
206 }
207 161
208 } 162 }
209 163
210 #endregion 164 #endregion
211 165
212 public XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request) 166 public static XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request)
213 { 167 {
214 168
215 m_log.Info("[IRC-Bridge]: XML RPC Admin Entry"); 169 m_log.Info("[IRC-Bridge]: XML RPC Admin Entry");
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs
index c52375d..636e9bf 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCConnector.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
57 private const int WD_INTERVAL = 1000; // base watchdog interval 57 private const int WD_INTERVAL = 1000; // base watchdog interval
58 private static int PING_PERIOD = 15; // WD intervals per PING 58 private static int PING_PERIOD = 15; // WD intervals per PING
59 private static int ICCD_PERIOD = 10; // WD intervals between Connects 59 private static int ICCD_PERIOD = 10; // WD intervals between Connects
60 private static int L_TIMEOUT = 10; // Login time out interval
60 61
61 private static int _idk_ = 0; // core connector identifier 62 private static int _idk_ = 0; // core connector identifier
62 private static int _pdk_ = 0; // ping interval counter 63 private static int _pdk_ = 0; // ping interval counter
@@ -118,6 +119,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
118 } 119 }
119 120
120 private bool m_connected = false; // connection status 121 private bool m_connected = false; // connection status
122 private bool m_pending = false; // login disposition
123 private int m_timeout = L_TIMEOUT; // login timeout counter
121 public bool Connected 124 public bool Connected
122 { 125 {
123 get { return m_connected; } 126 get { return m_connected; }
@@ -326,6 +329,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
326 if (m_connected) return; 329 if (m_connected) return;
327 330
328 m_connected = true; 331 m_connected = true;
332 m_pending = true;
333 m_timeout = L_TIMEOUT;
329 334
330 m_tcp = new TcpClient(m_server, (int)m_port); 335 m_tcp = new TcpClient(m_server, (int)m_port);
331 m_stream = m_tcp.GetStream(); 336 m_stream = m_tcp.GetStream();
@@ -349,8 +354,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
349 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel)); 354 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel));
350 m_writer.Flush(); 355 m_writer.Flush();
351 356
352 m_log.InfoFormat("[IRC-Connector-{0}]: {1} has joined {2}", idn, m_nick, m_ircChannel); 357 m_log.InfoFormat("[IRC-Connector-{0}]: {1} has asked to join {2}", idn, m_nick, m_ircChannel);
353 m_log.InfoFormat("[IRC-Connector-{0}] Connected", idn);
354 358
355 } 359 }
356 catch (Exception e) 360 catch (Exception e)
@@ -358,6 +362,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
358 m_log.ErrorFormat("[IRC-Connector-{0}] cannot connect {1} to {2}:{3}: {4}", 362 m_log.ErrorFormat("[IRC-Connector-{0}] cannot connect {1} to {2}:{3}: {4}",
359 idn, m_nick, m_server, m_port, e.Message); 363 idn, m_nick, m_server, m_port, e.Message);
360 m_connected = false; 364 m_connected = false;
365 m_pending = false;
361 } 366 }
362 367
363 } 368 }
@@ -396,6 +401,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
396 try { m_tcp.Close(); } catch (Exception) {} 401 try { m_tcp.Close(); } catch (Exception) {}
397 402
398 m_connected = false; 403 m_connected = false;
404 m_pending = false;
399 405
400 } 406 }
401 407
@@ -516,7 +522,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
516 // m_log.Debug(e); 522 // m_log.Debug(e);
517 } 523 }
518 524
525 // This is potentially circular, but harmless if so.
526 // The connection is marked as not connected the first time
527 // through reconnect.
528
519 if (m_enabled) Reconnect(); 529 if (m_enabled) Reconnect();
530
520 } 531 }
521 532
522 private Regex RE = new Regex(@":(?<nick>[\w-]*)!(?<user>\S*) PRIVMSG (?<channel>\S+) :(?<msg>.*)", 533 private Regex RE = new Regex(@":(?<nick>[\w-]*)!(?<user>\S*) PRIVMSG (?<channel>\S+) :(?<msg>.*)",
@@ -615,7 +626,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
615 case "003" : // Welcome ... 626 case "003" : // Welcome ...
616 break; 627 break;
617 case "004" : // Server information 628 case "004" : // Server information
618 m_log.DebugFormat("[IRC-Connector-{0}] parms = <{1}>", idn, parms); 629 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
619 commArgs = parms.Split(CS_SPACE); 630 commArgs = parms.Split(CS_SPACE);
620 c_server = commArgs[1]; 631 c_server = commArgs[1];
621 m_server = c_server; 632 m_server = c_server;
@@ -639,10 +650,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
639 case "366" : // End-of-Name list marker 650 case "366" : // End-of-Name list marker
640 case "372" : // MOTD body 651 case "372" : // MOTD body
641 case "375" : // MOTD start 652 case "375" : // MOTD start
642 m_log.InfoFormat("[IRC-Connector-{0}] {1}", idn, parms.Split(CS_SPACE,2)[1]); 653 m_log.InfoFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]);
643 break; 654 break;
644 case "376" : // MOTD end 655 case "376" : // MOTD end
645 m_log.InfoFormat("[IRC-Connector-{0}] {1}", idn, parms.Split(CS_SPACE,2)[1]); 656 m_log.InfoFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]);
646 motd = true; 657 motd = true;
647 break; 658 break;
648 case "451" : // Not registered 659 case "451" : // Not registered
@@ -650,7 +661,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
650 case "433" : // Nickname in use 661 case "433" : // Nickname in use
651 // Gen a new name 662 // Gen a new name
652 m_nick = m_baseNick + Util.RandomClass.Next(1, 99); 663 m_nick = m_baseNick + Util.RandomClass.Next(1, 99);
653 m_log.ErrorFormat("[IRC-Connector-{0}]: IRC SERVER reports NicknameInUse, trying {1}", idn, m_nick); 664 m_log.ErrorFormat("[IRC-Connector-{0}]: [{1}] IRC SERVER reports NicknameInUse, trying {2}", idn, cmd, m_nick);
654 // Retry 665 // Retry
655 m_writer.WriteLine(String.Format("NICK {0}", m_nick)); 666 m_writer.WriteLine(String.Format("NICK {0}", m_nick));
656 m_writer.Flush(); 667 m_writer.Flush();
@@ -659,43 +670,57 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
659 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel)); 670 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel));
660 m_writer.Flush(); 671 m_writer.Flush();
661 break; 672 break;
673 case "479" : // Bad channel name, etc. This will never work, so disable the connection
674 m_log.ErrorFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]);
675 m_log.ErrorFormat("[IRC-Connector-{0}] [{1}] Connector disabled", idn, cmd);
676 m_enabled = false;
677 m_connected = false;
678 m_pending = false;
679 break;
662 case "NOTICE" : 680 case "NOTICE" :
663 m_log.WarnFormat("[IRC-Connector-{0}] {1}", idn, parms.Split(CS_SPACE,2)[1]); 681 m_log.WarnFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]);
664 break; 682 break;
665 case "ERROR" : 683 case "ERROR" :
666 m_log.ErrorFormat("[IRC-Connector-{0}] {1}", idn, parms.Split(CS_SPACE,2)[1]); 684 m_log.ErrorFormat("[IRC-Connector-{0}] [{1}] {2}", idn, cmd, parms.Split(CS_SPACE,2)[1]);
667 if (parms.Contains("reconnect too fast")) 685 if (parms.Contains("reconnect too fast"))
668 ICCD_PERIOD++; 686 ICCD_PERIOD++;
687 m_pending = false;
688 Reconnect();
669 break; 689 break;
670 case "PING" : 690 case "PING" :
671 m_log.DebugFormat("[IRC-Connector-{0}] parms = <{1}>", idn, parms); 691 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
672 m_writer.WriteLine(String.Format("PONG {0}", parms)); 692 m_writer.WriteLine(String.Format("PONG {0}", parms));
673 m_writer.Flush(); 693 m_writer.Flush();
674 break; 694 break;
675 case "PONG" : 695 case "PONG" :
676 break; 696 break;
677 case "JOIN": 697 case "JOIN":
678 m_log.DebugFormat("[IRC-Connector-{0}] parms = <{1}>", idn, parms); 698 if (m_pending)
699 {
700 m_log.InfoFormat("[IRC-Connector-{0}] [{1}] Connected", idn, cmd);
701 m_pending = false;
702 }
703 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
679 eventIrcJoin(pfx, cmd, parms); 704 eventIrcJoin(pfx, cmd, parms);
680 break; 705 break;
681 case "PART": 706 case "PART":
682 m_log.DebugFormat("[IRC-Connector-{0}] parms = <{1}>", idn, parms); 707 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
683 eventIrcPart(pfx, cmd, parms); 708 eventIrcPart(pfx, cmd, parms);
684 break; 709 break;
685 case "MODE": 710 case "MODE":
686 m_log.DebugFormat("[IRC-Connector-{0}] parms = <{1}>", idn, parms); 711 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
687 eventIrcMode(pfx, cmd, parms); 712 eventIrcMode(pfx, cmd, parms);
688 break; 713 break;
689 case "NICK": 714 case "NICK":
690 m_log.DebugFormat("[IRC-Connector-{0}] parms = <{1}>", idn, parms); 715 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
691 eventIrcNickChange(pfx, cmd, parms); 716 eventIrcNickChange(pfx, cmd, parms);
692 break; 717 break;
693 case "KICK": 718 case "KICK":
694 m_log.DebugFormat("[IRC-Connector-{0}] parms = <{1}>", idn, parms); 719 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
695 eventIrcKick(pfx, cmd, parms); 720 eventIrcKick(pfx, cmd, parms);
696 break; 721 break;
697 case "QUIT": 722 case "QUIT":
698 m_log.DebugFormat("[IRC-Connector-{0}] parms = <{1}>", idn, parms); 723 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
699 eventIrcQuit(pfx, cmd, parms); 724 eventIrcQuit(pfx, cmd, parms);
700 break; 725 break;
701 default : 726 default :
@@ -813,6 +838,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
813 } 838 }
814 else 839 else
815 { 840 {
841
842 if (connector.m_pending)
843 {
844 if (connector.m_timeout == 0)
845 {
846 m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn);
847 connector.Reconnect();
848 }
849 else
850 connector.m_timeout--;
851 }
852
816 if (_pdk_ == 0) 853 if (_pdk_ == 0)
817 { 854 {
818 try 855 try
@@ -827,6 +864,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
827 connector.Reconnect(); 864 connector.Reconnect();
828 } 865 }
829 } 866 }
867
830 } 868 }
831 } 869 }
832 } 870 }
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/RegionState.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/RegionState.cs
index 0251388..b5cc3be 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/RegionState.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/RegionState.cs
@@ -123,6 +123,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
123 } 123 }
124 124
125 // Called by IRCBridgeModule.Close immediately prior to unload 125 // Called by IRCBridgeModule.Close immediately prior to unload
126 // of the module for this region. This happens when the region
127 // is being removed or the server is terminating. The IRC
128 // BridgeModule will remove the region from the region list
129 // when control returns.
126 130
127 public void Close() 131 public void Close()
128 { 132 {