Make copying of scripts into prim inventories more reliable on the first attempt when the asset server is lagging by formalising the de facto polling.
This may not be the best solution in the long run, but should improve things for now. This may also improve reliability when updating inventory item metadata (e.g. renaming an item) and in retrieving textures for the main map view.afrisby
parent
ed0f8bd572
commit
c470efea57
|
@ -156,16 +156,58 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get an asset. If the asset isn't in the cache, a request will be made to the persistent store to
|
||||||
|
/// load it into the cache.
|
||||||
|
///
|
||||||
|
/// XXX We'll keep polling the cache until we get the asset or we exceed
|
||||||
|
/// the allowed number of polls. This isn't a very good way of doing things since a single thread
|
||||||
|
/// is processing inbound packets, so if the asset server is slow, we could block this for up to
|
||||||
|
/// the timeout period. What we might want to do is register asynchronous callbacks on asset
|
||||||
|
/// receipt in the same manner as the nascent (but not yet active) TextureDownloadModule. Of course,
|
||||||
|
/// a timeout before asset receipt usually isn't fatal, the operation will work on the retry when the
|
||||||
|
/// asset is much more likely to have made it into the cache.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetID"></param>
|
||||||
|
/// <param name="isTexture"></param>
|
||||||
|
/// <returns>null if the asset could not be retrieved</returns>
|
||||||
public AssetBase GetAsset(LLUUID assetID, bool isTexture)
|
public AssetBase GetAsset(LLUUID assetID, bool isTexture)
|
||||||
{
|
{
|
||||||
|
// I'm not going over 3 seconds since this will be blocking processing of all the other inbound
|
||||||
|
// packets from the client.
|
||||||
|
int pollPeriod = 200;
|
||||||
|
int maxPolls = 15;
|
||||||
|
|
||||||
AssetBase asset = GetCachedAsset(assetID);
|
AssetBase asset = GetCachedAsset(assetID);
|
||||||
if (asset == null)
|
if (asset != null)
|
||||||
{
|
{
|
||||||
m_assetServer.RequestAsset(assetID, isTexture);
|
|
||||||
}
|
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_assetServer.RequestAsset(assetID, isTexture);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Thread.Sleep(pollPeriod);
|
||||||
|
|
||||||
|
asset = GetCachedAsset(assetID);
|
||||||
|
if (asset != null)
|
||||||
|
{
|
||||||
|
return asset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (--maxPolls > 0);
|
||||||
|
|
||||||
|
MainLog.Instance.Warn(
|
||||||
|
"ASSETCACHE", "Asset {0} was not received before the retrieval timeout was reached");
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an asset to both the persistent store and the cache.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="asset"></param>
|
||||||
public void AddAsset(AssetBase asset)
|
public void AddAsset(AssetBase asset)
|
||||||
{
|
{
|
||||||
string temporary = asset.Temporary ? "temporary" : "";
|
string temporary = asset.Temporary ? "temporary" : "";
|
||||||
|
|
|
@ -473,8 +473,6 @@ namespace OpenSim.Framework
|
||||||
event RegionInfoRequest OnRegionInfoRequest;
|
event RegionInfoRequest OnRegionInfoRequest;
|
||||||
event EstateCovenantRequest OnEstateCovenantRequest;
|
event EstateCovenantRequest OnEstateCovenantRequest;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LLVector3 StartPos { get; set; }
|
LLVector3 StartPos { get; set; }
|
||||||
|
|
||||||
LLUUID AgentId { get; }
|
LLUUID AgentId { get; }
|
||||||
|
@ -487,6 +485,13 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
string LastName { get; }
|
string LastName { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the full name of the agent/avatar represented by this client
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newPack"></param>
|
||||||
|
/// <param name="packType"></param>
|
||||||
|
string Name { get; }
|
||||||
|
|
||||||
uint CircuitCode { get; }
|
uint CircuitCode { get; }
|
||||||
|
|
||||||
void OutPacket(Packet newPack, ThrottleOutPacketType packType);
|
void OutPacket(Packet newPack, ThrottleOutPacketType packType);
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// First name of the agent/avatar represented by the client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FirstName
|
public string FirstName
|
||||||
{
|
{
|
||||||
|
@ -138,13 +138,21 @@ namespace OpenSim.Region.ClientStack
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Last name of the agent/avatar represented by the client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string LastName
|
public string LastName
|
||||||
{
|
{
|
||||||
get { return m_lastName; }
|
get { return m_lastName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Full name of the client (first name and last name)
|
||||||
|
/// </summary>
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return FirstName + " " + LastName; }
|
||||||
|
}
|
||||||
|
|
||||||
public uint CircuitCode
|
public uint CircuitCode
|
||||||
{
|
{
|
||||||
get { return m_circuitCode; }
|
get { return m_circuitCode; }
|
||||||
|
|
|
@ -429,16 +429,15 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
//group.AddInventoryItem(rmoteClient, primLocalID, null);
|
//group.AddInventoryItem(rmoteClient, primLocalID, null);
|
||||||
MainLog.Instance.Verbose(
|
MainLog.Instance.Verbose(
|
||||||
"PRIMINVENTORY",
|
"PRIMINVENTORY",
|
||||||
"UpdateTaskInventory called with item {0}, folder {1}, primLocalID {2}",
|
"UpdateTaskInventory called with script {0}, folder {1}, primLocalID {2}, user {3}",
|
||||||
itemID, folderID, primLocalID);
|
itemID, folderID, primLocalID, remoteClient.Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainLog.Instance.Warn(
|
MainLog.Instance.Warn(
|
||||||
"PRIMINVENTORY",
|
"PRIMINVENTORY",
|
||||||
"Update with item {0} requested of prim {1} but this prim does not exist",
|
"Update with script {0} requested of prim {1} for {2} but this prim does not exist",
|
||||||
itemID,
|
itemID, primLocalID, remoteClient.Name);
|
||||||
primLocalID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,13 +464,8 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
isTexture = true;
|
isTexture = true;
|
||||||
}
|
}
|
||||||
AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture);
|
|
||||||
|
|
||||||
if (rezAsset == null)
|
AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture);
|
||||||
{
|
|
||||||
// lets try once more in case the asset cache is being slow getting the asset from server
|
|
||||||
rezAsset = AssetCache.GetAsset(item.assetID, isTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rezAsset != null)
|
if (rezAsset != null)
|
||||||
{
|
{
|
||||||
|
@ -489,32 +483,35 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
// TODO: do we care about the value of this bool?
|
// TODO: do we care about the value of this bool?
|
||||||
group.AddInventoryItem(remoteClient, localID, item, copyID);
|
group.AddInventoryItem(remoteClient, localID, item, copyID);
|
||||||
group.GetProperites(remoteClient);
|
group.GetProperites(remoteClient);
|
||||||
|
|
||||||
|
MainLog.Instance.Verbose(
|
||||||
|
"PRIMINVENTORY",
|
||||||
|
"Rezzed script {0} (asset {1}) into prim {2} for user {3}",
|
||||||
|
item.inventoryName, rezAsset.FullID, localID, remoteClient.Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainLog.Instance.Warn(
|
MainLog.Instance.Warn(
|
||||||
"PRIMINVENTORY",
|
"PRIMINVENTORY",
|
||||||
"Could not rez item {0} into prim {1}"
|
"Could not rez script {0} into prim {1} for user {2}"
|
||||||
+ " because the prim could not be found in the region!",
|
+ " because the prim could not be found in the region!",
|
||||||
item.inventoryName,
|
item.inventoryName, localID, remoteClient.Name);
|
||||||
localID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainLog.Instance.Warn(
|
MainLog.Instance.Warn(
|
||||||
"PRIMINVENTORY",
|
"PRIMINVENTORY",
|
||||||
"Could not rez item {0} into prim {1}"
|
"Could not rez script {0} into prim {1} for user {2}"
|
||||||
+ " because the item asset {2} could not be found!",
|
+ " because the item asset {3} could not be found!",
|
||||||
item.inventoryName,
|
item.inventoryName, localID, item.assetID, remoteClient.Name);
|
||||||
localID,
|
|
||||||
item.assetID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainLog.Instance.Warn(
|
MainLog.Instance.Warn(
|
||||||
"PRIMINVENTORY", "Could not find script inventory item {0} to rez!", itemID);
|
"PRIMINVENTORY", "Could not find script inventory item {0} to rez for {1}!",
|
||||||
|
itemID, remoteClient.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -625,12 +622,6 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
AssetBase rezAsset = AssetCache.GetAsset(item.assetID, false);
|
AssetBase rezAsset = AssetCache.GetAsset(item.assetID, false);
|
||||||
|
|
||||||
if (rezAsset == null)
|
|
||||||
{
|
|
||||||
// lets try once more in case the asset cache is being slow getting the asset from server
|
|
||||||
rezAsset = AssetCache.GetAsset(item.assetID, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rezAsset != null)
|
if (rezAsset != null)
|
||||||
{
|
{
|
||||||
AddRezObject(Util.FieldToString(rezAsset.Data), pos);
|
AddRezObject(Util.FieldToString(rezAsset.Data), pos);
|
||||||
|
|
|
@ -186,6 +186,11 @@ namespace SimpleApp
|
||||||
get { return lastName; }
|
get { return lastName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual String Name
|
||||||
|
{
|
||||||
|
get { return FirstName + LastName; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual void OutPacket(Packet newPack, ThrottleOutPacketType packType)
|
public virtual void OutPacket(Packet newPack, ThrottleOutPacketType packType)
|
||||||
{
|
{
|
||||||
|
@ -394,8 +399,6 @@ namespace SimpleApp
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
Encoding enc = Encoding.ASCII;
|
|
||||||
|
|
||||||
if (OnAgentUpdate != null)
|
if (OnAgentUpdate != null)
|
||||||
{
|
{
|
||||||
AgentUpdatePacket pack = new AgentUpdatePacket();
|
AgentUpdatePacket pack = new AgentUpdatePacket();
|
||||||
|
|
Loading…
Reference in New Issue