Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor

avinationmerge
sacha 2010-12-23 08:14:43 +00:00
commit 98f0b4c72a
19 changed files with 234 additions and 176 deletions

View File

@ -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)

View File

@ -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();

View File

@ -1344,7 +1344,11 @@ namespace OpenSim.Framework.Capabilities
/// <returns></returns>
public string uploaderCaps(byte[] data, string path, string param)
{
m_log.WarnFormat("[CAPS] baked texture upload completed for {0}",newAssetID);
handlerUpLoad = OnUpLoad;
if (handlerUpLoad != null)
{
Util.FireAndForget(delegate(object o) { handlerUpLoad(newAssetID, data); });
}
string res = String.Empty;
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
@ -1356,12 +1360,6 @@ namespace OpenSim.Framework.Capabilities
httpListener.RemoveStreamHandler("POST", uploaderPath);
handlerUpLoad = OnUpLoad;
if (handlerUpLoad != null)
{
handlerUpLoad(newAssetID, data);
}
m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID);
return res;

View File

@ -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,

View File

@ -53,8 +53,8 @@ namespace OpenSim.Framework.Servers.HttpServer
private static byte[] ReadFully(Stream stream)
{
byte[] buffer = new byte[32768];
using (MemoryStream ms = new MemoryStream())
byte[] buffer = new byte[1024];
using (MemoryStream ms = new MemoryStream(1024*256))
{
while (true)
{

View File

@ -127,7 +127,7 @@ namespace OpenSim.Framework
m_threads.Add(threadInfo.Thread.ManagedThreadId, threadInfo);
}
private static bool RemoveThread(int threadID)
public static bool RemoveThread(int threadID)
{
lock (m_threads)
return m_threads.Remove(threadID);

View File

@ -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,

View File

@ -40,8 +40,8 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
private Scene m_scene;
private Dictionary<string, XferRequest> Requests = new Dictionary<string, XferRequest>();
private List<XferRequest> RequestTime = new List<XferRequest>();
public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>();
private Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
public struct XferRequest
@ -52,6 +52,12 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
public DateTime timeStamp;
}
private class FileData
{
public byte[] Data;
public int Count;
}
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
@ -89,20 +95,22 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
lock (NewFiles)
{
if (NewFiles.ContainsKey(fileName))
{
NewFiles[fileName] = data;
}
NewFiles[fileName].Count++;
else
{
NewFiles.Add(fileName, data);
FileData fd = new FileData();
fd.Count = 1;
fd.Data = data;
NewFiles.Add(fileName, fd);
}
}
if (Requests.ContainsKey(fileName))
{
RequestXfer(Requests[fileName].remoteClient, Requests[fileName].xferID, fileName);
Requests.Remove(fileName);
}
// This should not be here
//if (Requests.ContainsKey(fileName))
//{
// RequestXfer(Requests[fileName].remoteClient, Requests[fileName].xferID, fileName);
// Requests.Remove(fileName);
//}
return true;
}
@ -113,6 +121,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
{
client.OnRequestXfer += RequestXfer;
client.OnConfirmXfer += AckPacket;
client.OnAbortXfer += AbortXfer;
}
/// <summary>
@ -125,20 +134,35 @@ 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);
RemoveOrDecrement(fileName);
}
}
if (NewFiles.ContainsKey(fileName))
{
if (!Transfers.ContainsKey(xferID))
{
byte[] fileData = NewFiles[fileName];
byte[] fileData = NewFiles[fileName].Data;
XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
Transfers.Add(xferID, transaction);
NewFiles.Remove(fileName);
if (transaction.StartSend())
{
Transfers.Remove(xferID);
RemoveXferData(xferID);
}
// The transaction for this file is either complete or on its way
RemoveOrDecrement(fileName);
}
}
else
@ -150,6 +174,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,19 +191,81 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
}
}
}
}
public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet)
{
lock (NewFiles) // This is actually to lock Transfers
{
if (Transfers.ContainsKey(xferID))
{
XferDownLoad dl = Transfers[xferID];
if (Transfers[xferID].AckPacket(packet))
{
{
RemoveXferData(xferID);
RemoveOrDecrement(dl.FileName);
}
}
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 (Requests.ContainsKey(xferItem.FileName))
Requests.Remove(xferItem.FileName);
}
}
public void AbortXfer(IClientAPI remoteClient, ulong xferID)
{
lock (NewFiles)
{
if (Transfers.ContainsKey(xferID))
RemoveOrDecrement(Transfers[xferID].FileName);
RemoveXferData(xferID);
}
}
private void RemoveOrDecrement(string fileName)
{
// NewFiles must be locked
if (NewFiles.ContainsKey(fileName))
{
if (NewFiles[fileName].Count == 1)
NewFiles.Remove(fileName);
else
NewFiles[fileName].Count--;
}
}

View File

@ -620,8 +620,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
}
catch (WebException e)
{
m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0}} the host didn't respond ({2})",
reginfo.ServerURI, e.Message);
m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} the host didn't respond " + e.ToString(), reginfo.ServerURI.ToString());
}
return false;

View File

@ -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,

View File

@ -195,13 +195,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// in this prim's inventory.</returns>
int RemoveInventoryItem(UUID itemID);
/// <summary>
/// Return the name with which a client can request a xfer of this prim's inventory metadata
/// </summary>
string GetInventoryFileName();
bool GetInventoryFileName(IClientAPI client, uint localID);
/// <summary>
/// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
/// </summary>

View File

@ -951,23 +951,12 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="primLocalID"></param>
public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
{
SceneObjectGroup group = GetGroupByPrim(primLocalID);
if (group != null)
{
bool fileChange = group.GetPartInventoryFileName(remoteClient, primLocalID);
if (fileChange)
{
SceneObjectPart part = GetSceneObjectPart(primLocalID);
if (part == null)
return;
if (XferManager != null)
{
group.RequestInventoryFile(remoteClient, primLocalID, XferManager);
}
}
}
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: Inventory requested of prim {0} which doesn't exist", primLocalID);
}
part.Inventory.RequestInventoryFile(remoteClient, XferManager);
}
/// <summary>

View File

@ -1093,6 +1093,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
HeartbeatThread.Abort();
Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
HeartbeatThread = null;
}
m_lastUpdate = Util.EnvironmentTickCount();
@ -4801,7 +4802,7 @@ namespace OpenSim.Region.Framework.Scenes
if (m_firstHeartbeat)
return;
if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000)
StartTimer();
}

View File

@ -76,49 +76,6 @@ namespace OpenSim.Region.Framework.Scenes
parts[i].Inventory.RemoveScriptInstances(sceneObjectBeingDeleted);
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="localID"></param>
public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID)
{
SceneObjectPart part = GetChildPart(localID);
if (part != null)
{
return part.Inventory.GetInventoryFileName(remoteClient, localID);
}
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Couldn't find part {0} in object group {1}, {2} to retreive prim inventory",
localID, Name, UUID);
}
return false;
}
/// <summary>
/// Return serialized inventory metadata for the given constituent prim
/// </summary>
/// <param name="localID"></param>
/// <param name="xferManager"></param>
public void RequestInventoryFile(IClientAPI client, uint localID, IXfer xferManager)
{
SceneObjectPart part = GetChildPart(localID);
if (part != null)
{
part.Inventory.RequestInventoryFile(client, xferManager);
}
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Couldn't find part {0} in object group {1}, {2} to request inventory data",
localID, Name, UUID);
}
}
/// <summary>
/// Add an inventory item to a prim in this group.
/// </summary>

View File

@ -46,7 +46,8 @@ namespace OpenSim.Region.Framework.Scenes
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_inventoryFileName = String.Empty;
private int m_inventoryFileNameSerial = 0;
private byte[] m_inventoryFileData = new byte[0];
private uint m_inventoryFileNameSerial = 0;
private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>();
@ -930,40 +931,18 @@ namespace OpenSim.Region.Framework.Scenes
return -1;
}
public string GetInventoryFileName()
private bool CreateInventoryFileName()
{
if (m_inventoryFileName == String.Empty)
m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp";
if (m_inventoryFileNameSerial < m_inventorySerial)
if (m_inventoryFileName == String.Empty ||
m_inventoryFileNameSerial < m_inventorySerial)
{
m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp";
}
return m_inventoryFileName;
}
/// <summary>
/// Return the name with which a client can request a xfer of this prim's inventory metadata
/// </summary>
/// <param name="client"></param>
/// <param name="localID"></param>
public bool GetInventoryFileName(IClientAPI client, uint localID)
{
// m_log.DebugFormat(
// "[PRIM INVENTORY]: Received request from client {0} for inventory file name of {1}, {2}",
// client.AgentId, Name, UUID);
if (m_inventorySerial > 0)
{
client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
Utils.StringToBytes(GetInventoryFileName()));
m_inventoryFileNameSerial = m_inventorySerial;
return true;
}
else
{
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
return false;
}
}
/// <summary>
/// Serialize all the metadata for the items in this prim's inventory ready for sending to the client
@ -971,19 +950,37 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="xferManager"></param>
public void RequestInventoryFile(IClientAPI client, IXfer xferManager)
{
byte[] fileData = new byte[0];
bool changed = CreateInventoryFileName();
// Confusingly, the folder item has to be the object id, while the 'parent id' has to be zero. This matches
// what appears to happen in the Second Life protocol. If this isn't the case. then various functionality
// isn't available (such as drag from prim inventory to agent inventory)
InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
Items.LockItemsForRead(true);
if (m_inventorySerial == 0) // No inventory
{
client.SendTaskInventory(m_part.UUID, 0, new byte[0]);
Items.LockItemsForRead(false);
return;
}
client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial,
Util.StringToBytes256(m_inventoryFileName));
if (!changed)
{
if (m_inventoryFileData.Length > 2)
{
xferManager.AddNewFile(m_inventoryFileName,
m_inventoryFileData);
Items.LockItemsForRead(false);
return;
}
}
bool includeAssets = false;
if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId))
includeAssets = true;
lock (m_items)
{
foreach (TaskInventoryItem item in m_items.Values)
{
UUID ownerID = item.OwnerID;
@ -1031,18 +1028,14 @@ namespace OpenSim.Region.Framework.Scenes
invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
invString.AddSectionEnd();
}
}
int count = m_items.Count;
m_items.LockItemsForRead(false);
fileData = Utils.StringToBytes(invString.BuildString);
Items.LockItemsForRead(false);
//m_log.Debug(Utils.BytesToString(fileData));
//m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Utils.BytesToString(fileData));
m_inventoryFileData = Utils.StringToBytes(invString.BuildString);
if (fileData.Length > 2)
if (m_inventoryFileData.Length > 2)
{
xferManager.AddNewFile(m_inventoryFileName, fileData);
xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData);
}
}

View File

@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes
g.ScheduleFullUpdateToAvatar(m_presence);
}
while (m_partsUpdateQueue.Count > 0)
while (m_partsUpdateQueue.Count != null && m_partsUpdateQueue.Count > 0)
{
SceneObjectPart part = m_partsUpdateQueue.Dequeue();

View File

@ -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)
{

View File

@ -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,

View File

@ -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,