From ce8b9e6c570f73a5c70dfc2b52bbb595637b717d Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 19 Jul 2012 12:27:36 +0200 Subject: [PATCH 1/3] Fix slow loading of task inventory --- OpenSim/Framework/IClientAPI.cs | 2 +- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 10 +++++++--- OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | 11 +++++++---- .../InternetRelayClientView/Server/IRCClientView.cs | 2 +- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- OpenSim/Tests/Common/Mock/TestClient.cs | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 58a65de0c7..b1f41b84c6 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1177,7 +1177,7 @@ namespace OpenSim.Framework /// void SendBulkUpdateInventory(InventoryNodeBase node); - void SendXferPacket(ulong xferID, uint packet, byte[] data); + void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory); void SendAbortXferPacket(ulong xferID); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index e6289bd96c..ad9074cde4 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -2122,16 +2122,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP replytask.InventoryData.TaskID = taskID; replytask.InventoryData.Serial = serial; replytask.InventoryData.Filename = fileName; - OutPacket(replytask, ThrottleOutPacketType.Asset); + OutPacket(replytask, ThrottleOutPacketType.Task); } - public void SendXferPacket(ulong xferID, uint packet, byte[] data) + public void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) { + ThrottleOutPacketType type = ThrottleOutPacketType.Asset; + if (isTaskInventory) + type = ThrottleOutPacketType.Task; + SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket); sendXfer.XferID.ID = xferID; sendXfer.XferID.Packet = packet; sendXfer.DataPacket.Data = data; - OutPacket(sendXfer, ThrottleOutPacketType.Asset); + OutPacket(sendXfer, type); } public void SendAbortXferPacket(ulong xferID) diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index b8e2820db7..78d597d7c6 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs @@ -145,6 +145,8 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer { byte[] fileData = NewFiles[fileName].Data; XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); + if (fileName.StartsWith("inventory_")) + transaction.isTaskInventory = true; Transfers.Add(xferID, transaction); @@ -228,6 +230,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer public uint Packet = 0; public uint Serial = 1; public ulong XferID = 0; + public bool isTaskInventory = false; public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) { @@ -253,7 +256,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer byte[] transferData = new byte[Data.Length + 4]; Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); Array.Copy(Data, 0, transferData, 4, Data.Length); - Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); + Client.SendXferPacket(XferID, 0 + 0x80000000, transferData, isTaskInventory); complete = true; } else @@ -261,7 +264,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer byte[] transferData = new byte[1000 + 4]; Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); Array.Copy(Data, 0, transferData, 4, 1000); - Client.SendXferPacket(XferID, 0, transferData); + Client.SendXferPacket(XferID, 0, transferData, isTaskInventory); Packet++; DataPointer = 1000; } @@ -282,7 +285,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer { byte[] transferData = new byte[1000]; Array.Copy(Data, DataPointer, transferData, 0, 1000); - Client.SendXferPacket(XferID, Packet, transferData); + Client.SendXferPacket(XferID, Packet, transferData, isTaskInventory); Packet++; DataPointer += 1000; } @@ -291,7 +294,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer byte[] transferData = new byte[Data.Length - DataPointer]; Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); uint endPacket = Packet |= (uint) 0x80000000; - Client.SendXferPacket(XferID, endPacket, transferData); + Client.SendXferPacket(XferID, endPacket, transferData, isTaskInventory); Packet++; DataPointer += (Data.Length - DataPointer); diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 17a210bd25..86f33eb463 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1122,7 +1122,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } - public void SendXferPacket(ulong xferID, uint packet, byte[] data) + public void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) { } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 97db7e1e79..d00a6c0516 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -755,7 +755,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) + public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) { } public virtual void SendAbortXferPacket(ulong xferID) diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index e254dd8d5d..6add1305a8 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -732,7 +732,7 @@ namespace OpenSim.Tests.Common.Mock { } - public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) + public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) { } From 1598f9d1790d18f0ebd78bddc088b6e57829aca5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 20 Jul 2012 11:54:59 +0200 Subject: [PATCH 2/3] Fix the order of operations on detach. The object must always be serialized while still in the scene to avoid losing important script state. DeleteSceneObject can not be called before doing this! --- .../Avatar/Attachments/AttachmentsModule.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 394b90a691..f073c4abce 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -757,18 +757,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.EventManager.TriggerOnAttach(so.LocalId, so.FromItemID, UUID.Zero); sp.RemoveAttachment(so); - // We can only remove the script instances from the script engine after we've retrieved their xml state - // when we update the attachment item. - m_scene.DeleteSceneObject(so, false, false); - // Prepare sog for storage so.AttachedAvatar = UUID.Zero; so.RootPart.SetParentLocalId(0); so.IsAttachment = false; - so.AbsolutePosition = so.RootPart.AttachedPos; + + // We cannot use AbsolutePosition here because that would + // attempt to cross the prim as it is detached + so.ForEachPart(x => { x.GroupPosition = so.RootPart.AttachedPos; }); UpdateKnownItem(sp, so, true); - so.RemoveScriptInstances(true); + + // This MUST happen AFTER serialization because it will + // either stop or remove the scripts. Both will cause scripts + // to be serialized in a stopped state with the true run + // state already lost. + m_scene.DeleteSceneObject(so, false, true); } protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( From b1b3057adcc4f4acdf8207ea2733e6400cf7143a Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 21 Jul 2012 20:56:19 +0200 Subject: [PATCH 3/3] Fix double-ping on logout by not sending a stop packet to the client if the client told us it wants to log out in the first place. --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 79e35f4762..f5f9c029d4 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1516,7 +1516,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (!client.IsLoggingOut) { client.IsLoggingOut = true; - client.Close(); + client.Close(false); } } }