aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs42
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs48
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs6
3 files changed, 86 insertions, 10 deletions
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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife.Packets;
5
6namespace OpenSim.Region.ClientStack.LindenUDP
7{
8 class KillPacket : Packet
9 {
10 private Header header;
11 public override void FromBytes(Header header, byte[] bytes, ref int i, ref int packetEnd, byte[] zeroBuffer)
12 {
13
14 }
15
16 public override void FromBytes(byte[] bytes, ref int i, ref int packetEnd, byte[] zeroBuffer)
17 {
18
19 }
20
21 public override Header Header { get { return header; } set { header = value; }}
22
23 public override byte[] ToBytes()
24 {
25 return new byte[0];
26 }
27 public KillPacket()
28 {
29 Header = new LowHeader();
30 Header.ID = 65531;
31 Header.Reliable = true;
32 }
33
34 public override PacketType Type
35 {
36 get
37 {
38 return PacketType.UseCircuitCode;
39 }
40 }
41 }
42}
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
92 92
93 private Dictionary<string, LLUUID> m_defaultAnimations = new Dictionary<string, LLUUID>(); 93 private Dictionary<string, LLUUID> m_defaultAnimations = new Dictionary<string, LLUUID>();
94 94
95 private bool m_SendLogoutPacketWhenClosing = true;
96
95 /* protected variables */ 97 /* protected variables */
96 98
97 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = 99 protected static Dictionary<PacketType, PacketMethod> PacketHandlers =
@@ -368,6 +370,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
368 set { m_IsActive = value; } 370 set { m_IsActive = value; }
369 } 371 }
370 372
373 public bool SendLogoutPacketWhenClosing
374 {
375 set { m_SendLogoutPacketWhenClosing = value; }
376 }
377
371 /* METHODS */ 378 /* METHODS */
372 379
373 public LLClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, LLPacketServer packServer, 380 public LLClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, LLPacketServer packServer,
@@ -451,7 +458,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
451 if (!(shutdownCircuit)) 458 if (!(shutdownCircuit))
452 { 459 {
453 GC.Collect(); 460 GC.Collect();
454 m_clientThread.Abort(); 461
462 // Sends a KillPacket object, with which, the
463 // blockingqueue dequeues and sees it's a killpacket
464 // and terminates within the context of the client thread.
465 // This ensures that it's done from within the context
466 // of the client thread regardless of where Close() is called.
467 KillEndDone();
455 } 468 }
456 } 469 }
457 470
@@ -752,7 +765,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
752 ClientLoop(); 765 ClientLoop();
753 } 766 }
754 } 767 }
755 catch (Exception e) 768 catch (System.Exception e)
756 { 769 {
757 if (e is ThreadAbortException) 770 if (e is ThreadAbortException)
758 throw e; 771 throw e;
@@ -3740,6 +3753,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3740 m_PacketHandler.InPacket((Packet) NewPack); 3753 m_PacketHandler.InPacket((Packet) NewPack);
3741 } 3754 }
3742 3755
3756
3743 /// <summary> 3757 /// <summary>
3744 /// The dreaded OutPacket. This should only be called from within 3758 /// The dreaded OutPacket. This should only be called from within
3745 /// the ClientStack itself right now 3759 /// the ClientStack itself right now
@@ -6093,15 +6107,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6093 6107
6094 public void SendLogoutPacket() 6108 public void SendLogoutPacket()
6095 { 6109 {
6096 LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply); 6110 // I know this is a bit of a hack, however there are times when you don't
6097 // TODO: don't create new blocks if recycling an old packet 6111 // want to send this, but still need to do the rest of the shutdown process
6098 logReply.AgentData.AgentID = AgentId; 6112 // this method gets called from the packet server.. which makes it practically
6099 logReply.AgentData.SessionID = SessionId; 6113 // impossible to do any other way.
6100 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
6101 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
6102 logReply.InventoryData[0].ItemID = LLUUID.Zero;
6103 6114
6104 OutPacket(logReply, ThrottleOutPacketType.Task); 6115 if (m_SendLogoutPacketWhenClosing)
6116 {
6117 LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
6118 // TODO: don't create new blocks if recycling an old packet
6119 logReply.AgentData.AgentID = AgentId;
6120 logReply.AgentData.SessionID = SessionId;
6121 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
6122 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
6123 logReply.InventoryData[0].ItemID = LLUUID.Zero;
6124
6125 OutPacket(logReply, ThrottleOutPacketType.Task);
6126 }
6105 } 6127 }
6106 6128
6107 public void SendHealth(float health) 6129 public void SendHealth(float health)
@@ -6443,5 +6465,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6443 6465
6444 OutPacket(reply, ThrottleOutPacketType.Land); 6466 OutPacket(reply, ThrottleOutPacketType.Land);
6445 } 6467 }
6468
6469 public void KillEndDone()
6470 {
6471 KillPacket kp = new KillPacket();
6472 OutPacket(kp, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority);
6473 }
6446 } 6474 }
6447} 6475}
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;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Net.Sockets; 32using System.Net.Sockets;
33using System.Threading;
33using System.Timers; 34using System.Timers;
34using System.Reflection; 35using System.Reflection;
35using libsecondlife; 36using libsecondlife;
@@ -233,6 +234,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
233 // to. Packet drop notifies will not be triggered in this 234 // to. Packet drop notifies will not be triggered in this
234 // configuration! 235 // configuration!
235 // 236 //
237
236 if ((m_SynchronizeClient != null) && (!m_Client.IsActive)) 238 if ((m_SynchronizeClient != null) && (!m_Client.IsActive))
237 { 239 {
238 if (m_SynchronizeClient(m_Client.Scene, packet, 240 if (m_SynchronizeClient(m_Client.Scene, packet,
@@ -744,6 +746,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
744 } 746 }
745 } 747 }
746 748
749 // If we sent a killpacket
750 if (packet is KillPacket)
751 Thread.CurrentThread.Abort();
752
747 // Actually make the byte array and send it 753 // Actually make the byte array and send it
748 byte[] sendbuffer = packet.ToBytes(); 754 byte[] sendbuffer = packet.ToBytes();
749 755