* Fix for mantis 0000040 After client logout remote host closed connection on Simulator makes sim unuseable->'Closed Connection Called'

* I've fundamentally changed a few things, so this is experimental
* The routine that I used needs to be tested on Linux.  I don't expect it to cause a problem, but hey, it might.
* Child agents are still not logged off properly, so when the first set time out, the second set get logged off also, on the second log in if the second login is initiated before the first one fully times out.
afrisby
Teravus Ovares 2007-12-18 00:34:42 +00:00
parent 348e5b7648
commit afe63faa2e
6 changed files with 66 additions and 8 deletions

View File

@ -46,6 +46,7 @@ namespace OpenSim.Framework
void AddNewClient(IClientAPI client, bool child); void AddNewClient(IClientAPI client, bool child);
void RemoveClient(LLUUID agentID); void RemoveClient(LLUUID agentID);
void CloseAllAgents(uint circuitcode);
void Restart(int seconds); void Restart(int seconds);
bool OtherRegionUp(RegionInfo thisRegion); bool OtherRegionUp(RegionInfo thisRegion);

View File

@ -209,8 +209,8 @@ namespace OpenSim.Region.ClientStack
m_scene.RemoveClient(AgentId); m_scene.RemoveClient(AgentId);
// Send the STOP packet // Send the STOP packet
//libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); DisableSimulatorPacket disable = new DisableSimulatorPacket();
//OutPacket(disable, ThrottleOutPacketType.Task); OutPacket(disable, ThrottleOutPacketType.Task);
// FLUSH Packets // FLUSH Packets
m_packetQueue.Close(); m_packetQueue.Close();
@ -226,6 +226,10 @@ namespace OpenSim.Region.ClientStack
// flushing out all it's packets. There should probably // flushing out all it's packets. There should probably
// be a better mechanism here // be a better mechanism here
// We can't reach into other scenes and close the connection
// We need to do this over grid communications
m_scene.CloseAllAgents(CircuitCode);
m_clientThread.Abort(); m_clientThread.Abort();
} }

View File

@ -123,13 +123,16 @@ namespace OpenSim.Region.ClientStack
/// <param name="circuitcode"></param> /// <param name="circuitcode"></param>
public virtual void CloseCircuit(uint circuitcode) public virtual void CloseCircuit(uint circuitcode)
{ {
OpenSim.Framework.Console.MainLog.Instance.Debug("PACKETSERVER", "Removing Circuit Code");
m_networkHandler.RemoveClientCircuit(circuitcode); m_networkHandler.RemoveClientCircuit(circuitcode);
m_scene.ClientManager.CloseAllAgents(circuitcode); OpenSim.Framework.Console.MainLog.Instance.Debug("PACKETSERVER", "Removed Circuit Code");
//m_scene.ClientManager.CloseAllAgents(circuitcode);
} }
public virtual void CloseClient(IClientAPI client) public virtual void CloseClient(IClientAPI client)
{ {
CloseCircuit(client.CircuitCode); CloseCircuit(client.CircuitCode);
client.Close();
} }
} }
} }

View File

@ -119,16 +119,48 @@ namespace OpenSim.Region.ClientStack
{ {
case SocketError.AlreadyInProgress: case SocketError.AlreadyInProgress:
case SocketError.NetworkReset: case SocketError.NetworkReset:
default: case SocketError.ConnectionReset:
Console.WriteLine("Remote host Closed connection"); try
{
CloseEndPoint(epSender); CloseEndPoint(epSender);
}
catch (System.Exception a)
{
MainLog.Instance.Verbose("UDPSERVER", a.ToString());
}
try
{
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
// Ter: For some stupid reason ConnectionReset basically kills our async event structure..
// so therefore.. we've got to tell the server to BeginReceiveFrom again.
// This will happen over and over until we've gone through all packets
// sent to and from this particular user.
// Stupid I know..
// but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method.
}
catch (SocketException)
{
}
break;
default:
// Here's some reference code! :D
// Shutdown and restart the UDP listener! hehe
// Shiny
//Server.Shutdown(SocketShutdown.Both);
//CloseEndPoint(epSender);
//ServerListener();
break; break;
} }
return; return;
} }
catch (System.ObjectDisposedException) catch (System.ObjectDisposedException e)
{ {
MainLog.Instance.Debug("UDPSERVER", e.ToString());
return; return;
} }
@ -138,8 +170,9 @@ namespace OpenSim.Region.ClientStack
{ {
packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
} }
catch(Exception) catch(Exception e)
{ {
MainLog.Instance.Debug("UDPSERVER", e.ToString());
} }
// do we already have a circuit for this endpoint // do we already have a circuit for this endpoint
@ -147,18 +180,21 @@ namespace OpenSim.Region.ClientStack
if (clientCircuits.TryGetValue(epSender, out circuit)) if (clientCircuits.TryGetValue(epSender, out circuit))
{ {
//if so then send packet to the packetserver //if so then send packet to the packetserver
//MainLog.Instance.Warn("UDPSERVER", "ALREADY HAVE Circuit!");
m_packetServer.InPacket(circuit, packet); m_packetServer.InPacket(circuit, packet);
} }
else if (packet.Type == PacketType.UseCircuitCode) else if (packet.Type == PacketType.UseCircuitCode)
{ {
// new client // new client
MainLog.Instance.Debug("UDPSERVER", "Adding New Client");
AddNewClient(packet); AddNewClient(packet);
} }
else else
{ {
// invalid client // invalid client
//CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now
//CFK: m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString()); //m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString());
} }
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
@ -169,7 +205,9 @@ namespace OpenSim.Region.ClientStack
uint circuit; uint circuit;
if (clientCircuits.TryGetValue(sender, out circuit)) if (clientCircuits.TryGetValue(sender, out circuit))
{ {
MainLog.Instance.Debug("UDPSERVER", "CloseEndPoint:ClosingCircuit");
m_packetServer.CloseCircuit(circuit); m_packetServer.CloseCircuit(circuit);
MainLog.Instance.Debug("UDPSERVER", "CloseEndPoint:ClosedCircuit");
} }
} }
@ -222,8 +260,13 @@ namespace OpenSim.Region.ClientStack
EndPoint sendto = null; EndPoint sendto = null;
if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
{ {
MainLog.Instance.Debug("UDPSERVER", "RemovingClientCircuit");
clientCircuits.Remove(sendto); clientCircuits.Remove(sendto);
MainLog.Instance.Debug("UDPSERVER", "Removed Client Circuit");
MainLog.Instance.Debug("UDPSERVER", "Removing Reverse ClientCircuit");
clientCircuits_reverse.Remove(circuitcode); clientCircuits_reverse.Remove(circuitcode);
MainLog.Instance.Debug("UDPSERVER", "Removed Reverse ClientCircuit");
} }
} }
} }

View File

@ -1243,7 +1243,12 @@ namespace OpenSim.Region.Environment.Scenes
// Remove client agent from profile, so new logins will work // Remove client agent from profile, so new logins will work
CommsManager.UserService.clearUserAgent(agentID); CommsManager.UserService.clearUserAgent(agentID);
} }
public override void CloseAllAgents(uint circuitcode)
{
// Called by ClientView to kill all circuit codes
ClientManager.CloseAllAgents(circuitcode);
}
public void NotifyMyCoarseLocationChange() public void NotifyMyCoarseLocationChange()
{ {
ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); });

View File

@ -130,6 +130,8 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="agentID"></param> /// <param name="agentID"></param>
public abstract void RemoveClient(LLUUID agentID); public abstract void RemoveClient(LLUUID agentID);
public abstract void CloseAllAgents(uint circuitcode);
#endregion #endregion
/// <summary> /// <summary>