diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 06110c32cd..1f6dc5f71a 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -1131,6 +1131,12 @@ namespace OpenSim.Client.MXP.ClientStack // SL Specific, Ignore. (Remove from IClient) } + public void SendAbortXferPacket(ulong xferID) + { + + } + + public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent) { // SL Specific, Ignore. (Remove from IClient) diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index bc5dc9e417..8a49c6297a 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs @@ -675,6 +675,11 @@ namespace OpenSim.Client.VWoHTTP.ClientStack throw new System.NotImplementedException(); } + public virtual void SendAbortXferPacket(ulong xferID) + { + throw new System.NotImplementedException(); + } + public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent) { throw new System.NotImplementedException(); diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 1a59cf4c80..34ec42031a 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1062,6 +1062,8 @@ namespace OpenSim.Framework void SendXferPacket(ulong xferID, uint packet, byte[] data); + void SendAbortXferPacket(ulong xferID); + void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 00a605e988..6a6bd12fea 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -2097,6 +2097,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(sendXfer, ThrottleOutPacketType.Asset); } + public void SendAbortXferPacket(ulong xferID) + { + AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer); + xferItem.XferID.ID = xferID; + OutPacket(xferItem, ThrottleOutPacketType.Asset); + } + public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index ef7dce812e..57875dac26 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs @@ -97,6 +97,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer NewFiles.Add(fileName, data); } } + string filename = string.Empty; if (Requests.ContainsKey(fileName)) { @@ -113,6 +114,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer { client.OnRequestXfer += RequestXfer; client.OnConfirmXfer += AckPacket; + client.OnAbortXfer += AbortXfer; } /// @@ -125,6 +127,17 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer { lock (NewFiles) { + if (RequestTime.Count > 0) + { + TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks); + if (ts.TotalSeconds > 30) + { + ulong zxferid = RequestTime[0].xferID; + remoteClient.SendAbortXferPacket(zxferid); + RemoveXferData(zxferid); + } + } + if (NewFiles.ContainsKey(fileName)) { if (!Transfers.ContainsKey(xferID)) @@ -137,7 +150,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer if (transaction.StartSend()) { - Transfers.Remove(xferID); + RemoveXferData(xferID); } } } @@ -150,6 +163,8 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer { Requests.Remove(RequestTime[0].fileName); RequestTime.RemoveAt(0); + // Do we want to abort this here? + //remoteClient.SendAbortXfer(xferID); } } @@ -165,22 +180,69 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer } } + } } public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) { - if (Transfers.ContainsKey(xferID)) + lock (NewFiles) // This is actually to lock Transfers { - if (Transfers[xferID].AckPacket(packet)) + if (Transfers.ContainsKey(xferID)) { + XferDownLoad dl = Transfers[xferID]; + if (Transfers[xferID].AckPacket(packet)) { - Transfers.Remove(xferID); + { + RemoveXferData(xferID); + } + } + else + { + + if (Requests.ContainsKey(dl.FileName)) + { + // + XferRequest req = Requests[dl.FileName]; + req.timeStamp = DateTime.UtcNow; + Requests[dl.FileName] = req; + } } } } } + private void RemoveXferData(ulong xferID) + { + // NewFiles must be locked! + if (Transfers.ContainsKey(xferID)) + { + // Qualifier distinguishes between the OpenMetaverse version and the nested class + + XferModule.XferDownLoad xferItem = Transfers[xferID]; + //string filename = xferItem.FileName; + Transfers.Remove(xferID); + xferItem.Data = new byte[0]; // Clear the data + xferItem.DataPointer = 0; + + // If the abort comes in + if (NewFiles.ContainsKey(xferItem.FileName)) + NewFiles.Remove(xferItem.FileName); + + if (Requests.ContainsKey(xferItem.FileName)) + Requests.Remove(xferItem.FileName); + + } + } + + public void AbortXfer(IClientAPI remoteClient, ulong xferID) + { + lock (NewFiles) + { + RemoveXferData(xferID); + } + } + #region Nested type: XferDownLoad public class XferDownLoad diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 7441a60ff6..a6e2c03552 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -602,6 +602,12 @@ namespace OpenSim.Region.Examples.SimpleModule { } + public virtual void SendAbortXferPacket(ulong xferID) + { + + } + + public virtual void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 276e46dd3a..75f64418cc 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1123,6 +1123,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } + public void SendAbortXferPacket(ulong xferID) + { + + } + public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent) { diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 39c3364660..51949b4b3b 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -686,6 +686,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) { + } + public virtual void SendAbortXferPacket(ulong xferID) + { + } public virtual void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index fbc339a7ab..69a152f6ab 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -696,6 +696,11 @@ namespace OpenSim.Tests.Common.Mock { } + public virtual void SendAbortXferPacket(ulong xferID) + { + + } + public virtual void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,