Merge branch 'master' of opensimulator.org:/var/git/opensim
commit
f87d5d0780
|
@ -1303,7 +1303,7 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.WarnFormat("[UTILS]: Exception copying configuration file {0} to {1}: {2}", configFile, exampleConfigFile, e.Message);
|
m_log.WarnFormat("[UTILS]: Exception copying configuration file {0} to {1}: {2}", exampleConfigFile, configFile, e.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4796,7 +4796,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
block.SaleType = sop.ObjectSaleType;
|
block.SaleType = sop.ObjectSaleType;
|
||||||
block.SalePrice = sop.SalePrice;
|
block.SalePrice = sop.SalePrice;
|
||||||
block.Category = sop.Category;
|
block.Category = sop.Category;
|
||||||
block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
|
block.LastOwnerID = sop.LastOwnerID;
|
||||||
block.Name = Util.StringToBytes256(sop.Name);
|
block.Name = Util.StringToBytes256(sop.Name);
|
||||||
block.Description = Util.StringToBytes256(sop.Description);
|
block.Description = Util.StringToBytes256(sop.Description);
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Monitoring;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
|
@ -45,9 +47,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>();
|
private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>();
|
||||||
private Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
|
private Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
private object timeTickLock = new object();
|
||||||
|
private double lastTimeTick = 0.0;
|
||||||
|
private double lastFilesExpire = 0.0;
|
||||||
|
private bool inTimeTick = false;
|
||||||
|
|
||||||
public struct XferRequest
|
public struct XferRequest
|
||||||
{
|
{
|
||||||
public IClientAPI remoteClient;
|
public IClientAPI remoteClient;
|
||||||
|
@ -59,26 +65,30 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
|
||||||
private class FileData
|
private class FileData
|
||||||
{
|
{
|
||||||
public byte[] Data;
|
public byte[] Data;
|
||||||
public int Count;
|
public int refsCount;
|
||||||
|
public double timeStampMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region INonSharedRegionModule Members
|
#region INonSharedRegionModule Members
|
||||||
|
|
||||||
public void Initialise(IConfigSource config)
|
public void Initialise(IConfigSource config)
|
||||||
{
|
{
|
||||||
|
lastTimeTick = Util.GetTimeStampMS() + 30000.0;
|
||||||
|
lastFilesExpire = lastTimeTick + 180000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRegion(Scene scene)
|
public void AddRegion(Scene scene)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_scene.EventManager.OnNewClient += NewClient;
|
|
||||||
|
|
||||||
m_scene.RegisterModuleInterface<IXfer>(this);
|
m_scene.RegisterModuleInterface<IXfer>(this);
|
||||||
|
m_scene.EventManager.OnNewClient += NewClient;
|
||||||
|
m_scene.EventManager.OnRegionHeartbeatEnd += OnTimeTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveRegion(Scene scene)
|
public void RemoveRegion(Scene scene)
|
||||||
{
|
{
|
||||||
m_scene.EventManager.OnNewClient -= NewClient;
|
m_scene.EventManager.OnNewClient -= NewClient;
|
||||||
|
m_scene.EventManager.OnRegionHeartbeatEnd -= OnTimeTick;
|
||||||
|
|
||||||
m_scene.UnregisterModuleInterface<IXfer>(this);
|
m_scene.UnregisterModuleInterface<IXfer>(this);
|
||||||
m_scene = null;
|
m_scene = null;
|
||||||
|
@ -104,6 +114,35 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void OnTimeTick(Scene scene)
|
||||||
|
{
|
||||||
|
// we are on a heartbeat thread we there can be several
|
||||||
|
if(Monitor.TryEnter(timeTickLock))
|
||||||
|
{
|
||||||
|
if(!inTimeTick)
|
||||||
|
{
|
||||||
|
double now = Util.GetTimeStampMS();
|
||||||
|
if(now - lastTimeTick > 1750.0)
|
||||||
|
{
|
||||||
|
inTimeTick = true;
|
||||||
|
|
||||||
|
//don't overload busy heartbeat
|
||||||
|
WorkManager.RunInThread(
|
||||||
|
delegate
|
||||||
|
{
|
||||||
|
transfersTimeTick(now);
|
||||||
|
expireFiles(now);
|
||||||
|
|
||||||
|
lastTimeTick = now;
|
||||||
|
inTimeTick = false;
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
"XferTimeTick");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Monitor.Exit(timeTickLock);
|
||||||
|
}
|
||||||
|
}
|
||||||
#region IXfer Members
|
#region IXfer Members
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -118,24 +157,45 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
|
||||||
{
|
{
|
||||||
lock (NewFiles)
|
lock (NewFiles)
|
||||||
{
|
{
|
||||||
|
double now = Util.GetTimeStampMS();
|
||||||
if (NewFiles.ContainsKey(fileName))
|
if (NewFiles.ContainsKey(fileName))
|
||||||
{
|
{
|
||||||
NewFiles[fileName].Count++;
|
NewFiles[fileName].refsCount++;
|
||||||
NewFiles[fileName].Data = data;
|
NewFiles[fileName].Data = data;
|
||||||
|
NewFiles[fileName].timeStampMS = now;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FileData fd = new FileData();
|
FileData fd = new FileData();
|
||||||
fd.Count = 1;
|
fd.refsCount = 1;
|
||||||
fd.Data = data;
|
fd.Data = data;
|
||||||
|
fd.timeStampMS = now;
|
||||||
NewFiles.Add(fileName, fd);
|
NewFiles.Add(fileName, fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
public void expireFiles(double now)
|
||||||
|
{
|
||||||
|
lock (NewFiles)
|
||||||
|
{
|
||||||
|
// hopefully we will not have many files so nasty code will do it
|
||||||
|
if(now - lastFilesExpire > 120000.0)
|
||||||
|
{
|
||||||
|
lastFilesExpire = now;
|
||||||
|
List<string> expires = new List<string>();
|
||||||
|
foreach(string fname in NewFiles.Keys)
|
||||||
|
{
|
||||||
|
if(NewFiles[fname].refsCount == 0 && now - NewFiles[fname].timeStampMS > 120000.0)
|
||||||
|
expires.Add(fname);
|
||||||
|
}
|
||||||
|
foreach(string fname in expires)
|
||||||
|
NewFiles.Remove(fname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void NewClient(IClientAPI client)
|
public void NewClient(IClientAPI client)
|
||||||
{
|
{
|
||||||
|
@ -144,6 +204,51 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
|
||||||
client.OnAbortXfer += AbortXfer;
|
client.OnAbortXfer += AbortXfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnClientClosed(IClientAPI client)
|
||||||
|
{
|
||||||
|
client.OnRequestXfer -= RequestXfer;
|
||||||
|
client.OnConfirmXfer -= AckPacket;
|
||||||
|
client.OnAbortXfer -= AbortXfer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveOrDecrementFile(string fileName)
|
||||||
|
{
|
||||||
|
// NewFiles must be locked
|
||||||
|
|
||||||
|
if (NewFiles.ContainsKey(fileName))
|
||||||
|
{
|
||||||
|
if (NewFiles[fileName].refsCount == 1)
|
||||||
|
NewFiles.Remove(fileName);
|
||||||
|
else
|
||||||
|
NewFiles[fileName].refsCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void transfersTimeTick(double now)
|
||||||
|
{
|
||||||
|
XferDownLoad[] xfrs;
|
||||||
|
lock(Transfers)
|
||||||
|
{
|
||||||
|
if(Transfers.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
xfrs = new XferDownLoad[Transfers.Count];
|
||||||
|
Transfers.Values.CopyTo(xfrs,0);
|
||||||
|
}
|
||||||
|
foreach(XferDownLoad xfr in xfrs)
|
||||||
|
{
|
||||||
|
if(xfr.checkTime(now))
|
||||||
|
{
|
||||||
|
ulong xfrID = xfr.XferID;
|
||||||
|
lock(Transfers)
|
||||||
|
{
|
||||||
|
if(Transfers.ContainsKey(xfrID))
|
||||||
|
Transfers.Remove(xfrID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -155,81 +260,53 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
|
||||||
lock (NewFiles)
|
lock (NewFiles)
|
||||||
{
|
{
|
||||||
if (NewFiles.ContainsKey(fileName))
|
if (NewFiles.ContainsKey(fileName))
|
||||||
|
{
|
||||||
|
lock(Transfers)
|
||||||
{
|
{
|
||||||
if (!Transfers.ContainsKey(xferID))
|
if (!Transfers.ContainsKey(xferID))
|
||||||
{
|
{
|
||||||
byte[] fileData = NewFiles[fileName].Data;
|
byte[] fileData = NewFiles[fileName].Data;
|
||||||
XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
|
int burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Asset) >> 11;
|
||||||
if (fileName.StartsWith("inventory_"))
|
if(Transfers.Count > 1)
|
||||||
transaction.isTaskInventory = true;
|
burstSize /= Transfers.Count;
|
||||||
|
XferDownLoad transaction =
|
||||||
|
new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize);
|
||||||
|
|
||||||
Transfers.Add(xferID, transaction);
|
Transfers.Add(xferID, transaction);
|
||||||
|
|
||||||
if (transaction.StartSend())
|
transaction.StartSend();
|
||||||
RemoveXferData(xferID);
|
|
||||||
|
|
||||||
// The transaction for this file is either complete or on its way
|
|
||||||
RemoveOrDecrement(fileName);
|
|
||||||
|
|
||||||
|
// The transaction for this file is on its way
|
||||||
|
RemoveOrDecrementFile(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_log.WarnFormat("[Xfer]: {0} not found", fileName);
|
m_log.WarnFormat("[Xfer]: {0} not found", fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet)
|
public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet)
|
||||||
{
|
{
|
||||||
lock (NewFiles) // This is actually to lock Transfers
|
lock (Transfers)
|
||||||
{
|
{
|
||||||
if (Transfers.ContainsKey(xferID))
|
if (Transfers.ContainsKey(xferID))
|
||||||
{
|
{
|
||||||
XferDownLoad dl = Transfers[xferID];
|
|
||||||
if (Transfers[xferID].AckPacket(packet))
|
if (Transfers[xferID].AckPacket(packet))
|
||||||
{
|
|
||||||
RemoveXferData(xferID);
|
|
||||||
RemoveOrDecrement(dl.FileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RemoveXferData(ulong xferID)
|
|
||||||
{
|
|
||||||
// NewFiles must be locked!
|
|
||||||
if (Transfers.ContainsKey(xferID))
|
|
||||||
{
|
|
||||||
XferModule.XferDownLoad xferItem = Transfers[xferID];
|
|
||||||
//string filename = xferItem.FileName;
|
|
||||||
Transfers.Remove(xferID);
|
Transfers.Remove(xferID);
|
||||||
xferItem.Data = new byte[0]; // Clear the data
|
}
|
||||||
xferItem.DataPointer = 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AbortXfer(IClientAPI remoteClient, ulong xferID)
|
public void AbortXfer(IClientAPI remoteClient, ulong xferID)
|
||||||
{
|
{
|
||||||
lock (NewFiles)
|
lock (Transfers)
|
||||||
{
|
{
|
||||||
if (Transfers.ContainsKey(xferID))
|
if (Transfers.ContainsKey(xferID))
|
||||||
RemoveOrDecrement(Transfers[xferID].FileName);
|
|
||||||
|
|
||||||
RemoveXferData(xferID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RemoveOrDecrement(string fileName)
|
|
||||||
{
|
{
|
||||||
// NewFiles must be locked
|
Transfers[xferID].done();
|
||||||
|
Transfers.Remove(xferID);
|
||||||
if (NewFiles.ContainsKey(fileName))
|
}
|
||||||
{
|
|
||||||
if (NewFiles[fileName].Count == 1)
|
|
||||||
NewFiles.Remove(fileName);
|
|
||||||
else
|
|
||||||
NewFiles[fileName].Count--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,53 +315,124 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
|
||||||
public class XferDownLoad
|
public class XferDownLoad
|
||||||
{
|
{
|
||||||
public IClientAPI Client;
|
public IClientAPI Client;
|
||||||
private bool complete;
|
|
||||||
public byte[] Data = new byte[0];
|
public byte[] Data = new byte[0];
|
||||||
public int DataPointer = 0;
|
|
||||||
public string FileName = String.Empty;
|
public string FileName = String.Empty;
|
||||||
public uint Packet = 0;
|
|
||||||
public uint Serial = 1;
|
|
||||||
public ulong XferID = 0;
|
public ulong XferID = 0;
|
||||||
public bool isTaskInventory = false;
|
public bool isDeleted = false;
|
||||||
|
|
||||||
public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
|
private object myLock = new object();
|
||||||
|
private double lastsendTimeMS;
|
||||||
|
private int LastPacket;
|
||||||
|
private int lastBytes;
|
||||||
|
private int lastSentPacket;
|
||||||
|
private int lastAckPacket;
|
||||||
|
private int burstSize;
|
||||||
|
private int retries = 0;
|
||||||
|
|
||||||
|
public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client, int burstsz)
|
||||||
{
|
{
|
||||||
FileName = fileName;
|
FileName = fileName;
|
||||||
Data = data;
|
Data = data;
|
||||||
XferID = xferID;
|
XferID = xferID;
|
||||||
Client = client;
|
Client = client;
|
||||||
|
burstSize = burstsz;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XferDownLoad()
|
public XferDownLoad()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void done()
|
||||||
|
{
|
||||||
|
if(!isDeleted)
|
||||||
|
{
|
||||||
|
Data = new byte[0];
|
||||||
|
isDeleted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start a transfer
|
/// Start a transfer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>True if the transfer is complete, false if not</returns>
|
/// <returns>True if the transfer is complete, false if not</returns>
|
||||||
public bool StartSend()
|
public void StartSend()
|
||||||
{
|
{
|
||||||
if (Data.Length < 1000)
|
lock(myLock)
|
||||||
{
|
{
|
||||||
// for now (testing) we only support files under 1000 bytes
|
if(Data.Length == 0) //??
|
||||||
byte[] transferData = new byte[Data.Length + 4];
|
{
|
||||||
Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4);
|
LastPacket = 0;
|
||||||
Array.Copy(Data, 0, transferData, 4, Data.Length);
|
lastBytes = 0;
|
||||||
Client.SendXferPacket(XferID, 0 + 0x80000000, transferData, isTaskInventory);
|
burstSize = 0;
|
||||||
complete = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte[] transferData = new byte[1000 + 4];
|
// payload of 1024bytes
|
||||||
Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4);
|
LastPacket = Data.Length >> 10;
|
||||||
Array.Copy(Data, 0, transferData, 4, 1000);
|
lastBytes = Data.Length & 0x3ff;
|
||||||
Client.SendXferPacket(XferID, 0, transferData, isTaskInventory);
|
if(lastBytes == 0)
|
||||||
Packet++;
|
{
|
||||||
DataPointer = 1000;
|
lastBytes = 1024;
|
||||||
|
LastPacket--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return complete;
|
}
|
||||||
|
|
||||||
|
lastAckPacket = -1;
|
||||||
|
lastSentPacket = -1;
|
||||||
|
|
||||||
|
double now = Util.GetTimeStampMS();
|
||||||
|
|
||||||
|
SendBurst(now);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendBurst(double now)
|
||||||
|
{
|
||||||
|
int start = lastAckPacket + 1;
|
||||||
|
int end = start + burstSize;
|
||||||
|
if (end > LastPacket)
|
||||||
|
end = LastPacket;
|
||||||
|
while(start <= end)
|
||||||
|
SendPacket(start++ , now);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendPacket(int pkt, double now)
|
||||||
|
{
|
||||||
|
if(pkt > LastPacket)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int pktsize;
|
||||||
|
uint pktid;
|
||||||
|
if (pkt == LastPacket)
|
||||||
|
{
|
||||||
|
pktsize = lastBytes;
|
||||||
|
pktid = (uint)pkt | 0x80000000u;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pktsize = 1024;
|
||||||
|
pktid = (uint)pkt;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] transferData;
|
||||||
|
if(pkt == 0)
|
||||||
|
{
|
||||||
|
transferData = new byte[pktsize + 4];
|
||||||
|
Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4);
|
||||||
|
Array.Copy(Data, 0, transferData, 4, pktsize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transferData = new byte[pktsize];
|
||||||
|
Array.Copy(Data, pkt << 10, transferData, 0, pktsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
Client.SendXferPacket(XferID, pktid, transferData, false);
|
||||||
|
|
||||||
|
lastSentPacket = pkt;
|
||||||
|
lastsendTimeMS = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -294,30 +442,46 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
|
||||||
/// <returns>True if the transfer is complete, false otherwise</returns>
|
/// <returns>True if the transfer is complete, false otherwise</returns>
|
||||||
public bool AckPacket(uint packet)
|
public bool AckPacket(uint packet)
|
||||||
{
|
{
|
||||||
if (!complete)
|
lock(myLock)
|
||||||
{
|
{
|
||||||
if ((Data.Length - DataPointer) > 1000)
|
if(isDeleted)
|
||||||
{
|
return true;
|
||||||
byte[] transferData = new byte[1000];
|
|
||||||
Array.Copy(Data, DataPointer, transferData, 0, 1000);
|
|
||||||
Client.SendXferPacket(XferID, Packet, transferData, isTaskInventory);
|
|
||||||
Packet++;
|
|
||||||
DataPointer += 1000;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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, isTaskInventory);
|
|
||||||
Packet++;
|
|
||||||
DataPointer += (Data.Length - DataPointer);
|
|
||||||
|
|
||||||
complete = true;
|
packet &= 0x7fffffff;
|
||||||
|
if(lastAckPacket < packet)
|
||||||
|
lastAckPacket = (int)packet;
|
||||||
|
|
||||||
|
if(lastAckPacket == LastPacket)
|
||||||
|
{
|
||||||
|
done();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
double now = Util.GetTimeStampMS();
|
||||||
|
SendPacket(lastSentPacket + 1, now);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return complete;
|
public bool checkTime(double now)
|
||||||
|
{
|
||||||
|
if(Monitor.TryEnter(myLock))
|
||||||
|
{
|
||||||
|
if(!isDeleted)
|
||||||
|
{
|
||||||
|
double timeMS = now - lastsendTimeMS;
|
||||||
|
if(timeMS > 60000.0)
|
||||||
|
done();
|
||||||
|
else if(timeMS > 3500.0 && retries++ < 3)
|
||||||
|
{
|
||||||
|
burstSize >>= 1;
|
||||||
|
SendBurst(now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Monitor.Exit(myLock);
|
||||||
|
return isDeleted;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private byte[] m_inventoryFileData = new byte[0];
|
private byte[] m_inventoryFileData = new byte[0];
|
||||||
|
private byte[] m_inventoryFileNameBytes = new byte[0];
|
||||||
|
private string m_inventoryFileName = "";
|
||||||
private uint m_inventoryFileNameSerial = 0;
|
private uint m_inventoryFileNameSerial = 0;
|
||||||
private bool m_inventoryPrivileged = false;
|
private bool m_inventoryPrivileged = false;
|
||||||
private object m_inventoryFileLock = new object();
|
private object m_inventoryFileLock = new object();
|
||||||
|
@ -1112,18 +1114,34 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="xferManager"></param>
|
/// <param name="xferManager"></param>
|
||||||
public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
|
public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
|
||||||
{
|
{
|
||||||
|
|
||||||
lock (m_inventoryFileLock)
|
lock (m_inventoryFileLock)
|
||||||
{
|
{
|
||||||
string filename = "inventory_" + UUID.Random().ToString() + ".tmp";
|
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (m_inventoryFileNameSerial < m_inventorySerial)
|
|
||||||
|
Items.LockItemsForRead(true);
|
||||||
|
|
||||||
|
if (m_inventorySerial == 0) // No inventory
|
||||||
|
{
|
||||||
|
Items.LockItemsForRead(false);
|
||||||
|
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_items.Count == 0) // No inventory
|
||||||
|
{
|
||||||
|
Items.LockItemsForRead(false);
|
||||||
|
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_inventoryFileNameSerial != m_inventorySerial)
|
||||||
{
|
{
|
||||||
m_inventoryFileNameSerial = m_inventorySerial;
|
m_inventoryFileNameSerial = m_inventorySerial;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Items.LockItemsForRead(false);
|
||||||
|
|
||||||
if (m_inventoryFileData.Length < 2)
|
if (m_inventoryFileData.Length < 2)
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
|
@ -1134,32 +1152,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (m_inventoryPrivileged != includeAssets)
|
if (m_inventoryPrivileged != includeAssets)
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
|
|
||||||
Items.LockItemsForRead(true);
|
|
||||||
|
|
||||||
if (m_inventorySerial == 0) // No inventory
|
|
||||||
{
|
|
||||||
Items.LockItemsForRead(false);
|
|
||||||
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_items.Count == 0) // No inventory
|
|
||||||
{
|
|
||||||
Items.LockItemsForRead(false);
|
|
||||||
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
{
|
{
|
||||||
Items.LockItemsForRead(false);
|
xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
|
||||||
|
|
||||||
xferManager.AddNewFile(filename,
|
|
||||||
m_inventoryFileData);
|
|
||||||
client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
|
client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
|
||||||
Util.StringToBytes256(filename));
|
m_inventoryFileNameBytes);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1168,6 +1165,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
|
InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
|
||||||
|
|
||||||
|
Items.LockItemsForRead(true);
|
||||||
|
|
||||||
foreach (TaskInventoryItem item in m_items.Values)
|
foreach (TaskInventoryItem item in m_items.Values)
|
||||||
{
|
{
|
||||||
UUID ownerID = item.OwnerID;
|
UUID ownerID = item.OwnerID;
|
||||||
|
@ -1222,9 +1221,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
if (m_inventoryFileData.Length > 2)
|
if (m_inventoryFileData.Length > 2)
|
||||||
{
|
{
|
||||||
xferManager.AddNewFile(filename, m_inventoryFileData);
|
m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp";
|
||||||
client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,
|
m_inventoryFileNameBytes = Util.StringToBytes256(m_inventoryFileName);
|
||||||
Util.StringToBytes256(filename));
|
xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
|
||||||
|
client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial,m_inventoryFileNameBytes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1267,26 +1267,22 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
AddNameValueLine("obj_id", folderID.ToString());
|
AddNameValueLine("obj_id", folderID.ToString());
|
||||||
AddNameValueLine("parent_id", parentID.ToString());
|
AddNameValueLine("parent_id", parentID.ToString());
|
||||||
AddNameValueLine("type", "category");
|
AddNameValueLine("type", "category");
|
||||||
AddNameValueLine("name", "Contents|");
|
AddNameValueLine("name", "Contents|\n\t}");
|
||||||
AddSectionEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddItemStart()
|
public void AddItemStart()
|
||||||
{
|
{
|
||||||
BuildString.Append("\tinv_item\t0\n");
|
BuildString.Append("\tinv_item\t0\n\t{\n");
|
||||||
AddSectionStart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddPermissionsStart()
|
public void AddPermissionsStart()
|
||||||
{
|
{
|
||||||
BuildString.Append("\tpermissions 0\n");
|
BuildString.Append("\tpermissions 0\n\t{\n");
|
||||||
AddSectionStart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSaleStart()
|
public void AddSaleStart()
|
||||||
{
|
{
|
||||||
BuildString.Append("\tsale_info\t0\n");
|
BuildString.Append("\tsale_info\t0\n\t{\n");
|
||||||
AddSectionStart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddSectionStart()
|
protected void AddSectionStart()
|
||||||
|
@ -1307,8 +1303,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public void AddNameValueLine(string name, string value)
|
public void AddNameValueLine(string name, string value)
|
||||||
{
|
{
|
||||||
BuildString.Append("\t\t");
|
BuildString.Append("\t\t");
|
||||||
BuildString.Append(name + "\t");
|
BuildString.Append(name);
|
||||||
BuildString.Append(value + "\n");
|
BuildString.Append("\t");
|
||||||
|
BuildString.Append(value);
|
||||||
|
BuildString.Append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetString()
|
public String GetString()
|
||||||
|
|
Loading…
Reference in New Issue