From 2912aafe259727351eb9405532e45aa3501b7e9a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 25 Aug 2008 07:35:17 +0000 Subject: * This commit incorporates the heart of the OpenGridProtocol patch that is currently on Forge in a nice, friendly modular format. * There are a lot of changes and this is quite experimental. It's off by default, but you can turn it on by examining the bottom of the opensim.ini.example for the proper OpenSim.ini settings. Remember, you still need an agent domain.. * Furthermore, it isn't quite right when it comes to teleporting to remote regions (place_avatar) --- OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs | 42 +++++++++++++++++++ .../Region/ClientStack/LindenUDP/LLClientView.cs | 48 +++++++++++++++++----- .../ClientStack/LindenUDP/LLPacketHandler.cs | 6 +++ 3 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs new file mode 100644 index 0000000..dfdabc8 --- /dev/null +++ b/OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife.Packets; + +namespace OpenSim.Region.ClientStack.LindenUDP +{ + class KillPacket : Packet + { + private Header header; + public override void FromBytes(Header header, byte[] bytes, ref int i, ref int packetEnd, byte[] zeroBuffer) + { + + } + + public override void FromBytes(byte[] bytes, ref int i, ref int packetEnd, byte[] zeroBuffer) + { + + } + + public override Header Header { get { return header; } set { header = value; }} + + public override byte[] ToBytes() + { + return new byte[0]; + } + public KillPacket() + { + Header = new LowHeader(); + Header.ID = 65531; + Header.Reliable = true; + } + + public override PacketType Type + { + get + { + return PacketType.UseCircuitCode; + } + } + } +} diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 7c531f3..8214045 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -92,6 +92,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private Dictionary m_defaultAnimations = new Dictionary(); + private bool m_SendLogoutPacketWhenClosing = true; + /* protected variables */ protected static Dictionary PacketHandlers = @@ -368,6 +370,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP set { m_IsActive = value; } } + public bool SendLogoutPacketWhenClosing + { + set { m_SendLogoutPacketWhenClosing = value; } + } + /* METHODS */ public LLClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, LLPacketServer packServer, @@ -451,7 +458,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (!(shutdownCircuit)) { GC.Collect(); - m_clientThread.Abort(); + + // Sends a KillPacket object, with which, the + // blockingqueue dequeues and sees it's a killpacket + // and terminates within the context of the client thread. + // This ensures that it's done from within the context + // of the client thread regardless of where Close() is called. + KillEndDone(); } } @@ -752,7 +765,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP ClientLoop(); } } - catch (Exception e) + catch (System.Exception e) { if (e is ThreadAbortException) throw e; @@ -3740,6 +3753,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_PacketHandler.InPacket((Packet) NewPack); } + /// /// The dreaded OutPacket. This should only be called from within /// the ClientStack itself right now @@ -6093,15 +6107,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SendLogoutPacket() { - LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply); - // TODO: don't create new blocks if recycling an old packet - logReply.AgentData.AgentID = AgentId; - logReply.AgentData.SessionID = SessionId; - logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; - logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); - logReply.InventoryData[0].ItemID = LLUUID.Zero; + // I know this is a bit of a hack, however there are times when you don't + // want to send this, but still need to do the rest of the shutdown process + // this method gets called from the packet server.. which makes it practically + // impossible to do any other way. - OutPacket(logReply, ThrottleOutPacketType.Task); + if (m_SendLogoutPacketWhenClosing) + { + LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply); + // TODO: don't create new blocks if recycling an old packet + logReply.AgentData.AgentID = AgentId; + logReply.AgentData.SessionID = SessionId; + logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; + logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); + logReply.InventoryData[0].ItemID = LLUUID.Zero; + + OutPacket(logReply, ThrottleOutPacketType.Task); + } } public void SendHealth(float health) @@ -6443,5 +6465,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(reply, ThrottleOutPacketType.Land); } + + public void KillEndDone() + { + KillPacket kp = new KillPacket(); + OutPacket(kp, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); + } } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index 209ec36..830074a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs @@ -30,6 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.Net; using System.Net.Sockets; +using System.Threading; using System.Timers; using System.Reflection; using libsecondlife; @@ -233,6 +234,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // to. Packet drop notifies will not be triggered in this // configuration! // + if ((m_SynchronizeClient != null) && (!m_Client.IsActive)) { if (m_SynchronizeClient(m_Client.Scene, packet, @@ -744,6 +746,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + // If we sent a killpacket + if (packet is KillPacket) + Thread.CurrentThread.Abort(); + // Actually make the byte array and send it byte[] sendbuffer = packet.ToBytes(); -- cgit v1.1