Merge branch 'avination' into careminster

avinationmerge
Melanie 2013-02-07 21:26:55 +00:00
commit 8b78b9429d
9 changed files with 222 additions and 136 deletions

View File

@ -435,4 +435,4 @@ namespace OpenSim.Capabilities.Handlers
return llsdItem; return llsdItem;
} }
} }
} }

View File

@ -2157,4 +2157,112 @@ namespace OpenSim.Framework
return str.Replace("_", "\\_").Replace("%", "\\%"); return str.Replace("_", "\\_").Replace("%", "\\%");
} }
} }
public class DoubleQueue<T> where T:class
{
private Queue<T> m_lowQueue = new Queue<T>();
private Queue<T> m_highQueue = new Queue<T>();
private object m_syncRoot = new object();
private Semaphore m_s = new Semaphore(0, 1);
public DoubleQueue()
{
}
public virtual int Count
{
get { return m_highQueue.Count + m_lowQueue.Count; }
}
public virtual void Enqueue(T data)
{
Enqueue(m_lowQueue, data);
}
public virtual void EnqueueLow(T data)
{
Enqueue(m_lowQueue, data);
}
public virtual void EnqueueHigh(T data)
{
Enqueue(m_highQueue, data);
}
private void Enqueue(Queue<T> q, T data)
{
lock (m_syncRoot)
{
m_lowQueue.Enqueue(data);
m_s.WaitOne(0);
m_s.Release();
}
}
public virtual T Dequeue()
{
return Dequeue(Timeout.Infinite);
}
public virtual T Dequeue(int tmo)
{
return Dequeue(TimeSpan.FromMilliseconds(tmo));
}
public virtual T Dequeue(TimeSpan wait)
{
T res = null;
if (!Dequeue(wait, ref res))
return null;
return res;
}
public bool Dequeue(int timeout, ref T res)
{
return Dequeue(TimeSpan.FromMilliseconds(timeout), ref res);
}
public bool Dequeue(TimeSpan wait, ref T res)
{
if (!m_s.WaitOne(wait))
return false;
lock (m_syncRoot)
{
if (m_highQueue.Count > 0)
res = m_highQueue.Dequeue();
else
res = m_lowQueue.Dequeue();
if (m_highQueue.Count == 0 && m_lowQueue.Count == 0)
return true;
try
{
m_s.Release();
}
catch
{
}
return true;
}
}
public virtual void Clear()
{
lock (m_syncRoot)
{
// Make sure sem count is 0
m_s.WaitOne(0);
m_lowQueue.Clear();
m_highQueue.Clear();
}
}
}
} }

View File

@ -39,10 +39,13 @@ using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Framework.Capabilities;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps; using Caps = OpenSim.Framework.Capabilities.Caps;
using OpenSim.Capabilities.Handlers; using OpenSim.Capabilities.Handlers;
using OpenSim.Framework.Monitoring; using OpenSim.Framework.Monitoring;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Region.ClientStack.Linden namespace OpenSim.Region.ClientStack.Linden
{ {
@ -52,11 +55,13 @@ namespace OpenSim.Region.ClientStack.Linden
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")]
public class WebFetchInvDescModule : INonSharedRegionModule public class WebFetchInvDescModule : INonSharedRegionModule
{ {
struct aPollRequest class aPollRequest
{ {
public PollServiceInventoryEventArgs thepoll; public PollServiceInventoryEventArgs thepoll;
public UUID reqID; public UUID reqID;
public Hashtable request; public Hashtable request;
public ScenePresence presence;
public List<UUID> folders;
} }
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -71,8 +76,8 @@ namespace OpenSim.Region.ClientStack.Linden
private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
private static Thread[] m_workerThreads = null; private static Thread[] m_workerThreads = null;
private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue = private static DoubleQueue<aPollRequest> m_queue =
new OpenMetaverse.BlockingQueue<aPollRequest>(); new DoubleQueue<aPollRequest>();
#region ISharedRegionModule Members #region ISharedRegionModule Members
@ -143,12 +148,18 @@ namespace OpenSim.Region.ClientStack.Linden
private class PollServiceInventoryEventArgs : PollServiceEventArgs private class PollServiceInventoryEventArgs : PollServiceEventArgs
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<UUID, Hashtable> responses = private Dictionary<UUID, Hashtable> responses =
new Dictionary<UUID, Hashtable>(); new Dictionary<UUID, Hashtable>();
public PollServiceInventoryEventArgs(UUID pId) : private Scene m_scene;
public PollServiceInventoryEventArgs(Scene scene, UUID pId) :
base(null, null, null, null, pId, int.MaxValue) base(null, null, null, null, pId, int.MaxValue)
{ {
m_scene = scene;
HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); };
GetEvents = (x, y) => GetEvents = (x, y) =>
{ {
@ -167,12 +178,64 @@ namespace OpenSim.Region.ClientStack.Linden
Request = (x, y) => Request = (x, y) =>
{ {
ScenePresence sp = m_scene.GetScenePresence(Id);
if (sp == null)
{
m_log.ErrorFormat("[INVENTORY]: Unable to find ScenePresence for {0}", Id);
return;
}
aPollRequest reqinfo = new aPollRequest(); aPollRequest reqinfo = new aPollRequest();
reqinfo.thepoll = this; reqinfo.thepoll = this;
reqinfo.reqID = x; reqinfo.reqID = x;
reqinfo.request = y; reqinfo.request = y;
reqinfo.presence = sp;
reqinfo.folders = new List<UUID>();
m_queue.Enqueue(reqinfo); // Decode the request here
string request = y["body"].ToString();
request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>");
request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>");
request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>");
Hashtable hash = new Hashtable();
try
{
hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
}
catch (LLSD.LLSDParseException e)
{
m_log.ErrorFormat("[INVENTORY]: Fetch error: {0}{1}" + e.Message, e.StackTrace);
m_log.Error("Request: " + request);
return;
}
ArrayList foldersrequested = (ArrayList)hash["folders"];
bool highPriority = false;
for (int i = 0; i < foldersrequested.Count; i++)
{
Hashtable inventoryhash = (Hashtable)foldersrequested[i];
string folder = inventoryhash["folder_id"].ToString();
UUID folderID;
if (UUID.TryParse(folder, out folderID))
{
if (!reqinfo.folders.Contains(folderID))
{
if (sp.COF != UUID.Zero && sp.COF == folderID)
highPriority = true;
reqinfo.folders.Add(folderID);
}
}
}
if (highPriority)
m_queue.EnqueueHigh(reqinfo);
else
m_queue.EnqueueLow(reqinfo);
}; };
NoEvents = (x, y) => NoEvents = (x, y) =>
@ -208,7 +271,7 @@ namespace OpenSim.Region.ClientStack.Linden
response["reusecontext"] = false; response["reusecontext"] = false;
response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest( response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(
requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null);
lock (responses) lock (responses)
responses[requestID] = response; responses[requestID] = response;
@ -220,7 +283,7 @@ namespace OpenSim.Region.ClientStack.Linden
string capUrl = "/CAPS/" + UUID.Random() + "/"; string capUrl = "/CAPS/" + UUID.Random() + "/";
// Register this as a poll service // Register this as a poll service
PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(m_scene, agentID);
args.Type = PollServiceEventArgs.EventType.Inventory; args.Type = PollServiceEventArgs.EventType.Inventory;
MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args);

View File

@ -1903,112 +1903,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
} }
} }
internal class DoubleQueue<T> where T:class
{
private Queue<T> m_lowQueue = new Queue<T>();
private Queue<T> m_highQueue = new Queue<T>();
private object m_syncRoot = new object();
private Semaphore m_s = new Semaphore(0, 1);
public DoubleQueue()
{
}
public virtual int Count
{
get { return m_highQueue.Count + m_lowQueue.Count; }
}
public virtual void Enqueue(T data)
{
Enqueue(m_lowQueue, data);
}
public virtual void EnqueueLow(T data)
{
Enqueue(m_lowQueue, data);
}
public virtual void EnqueueHigh(T data)
{
Enqueue(m_highQueue, data);
}
private void Enqueue(Queue<T> q, T data)
{
lock (m_syncRoot)
{
m_lowQueue.Enqueue(data);
m_s.WaitOne(0);
m_s.Release();
}
}
public virtual T Dequeue()
{
return Dequeue(Timeout.Infinite);
}
public virtual T Dequeue(int tmo)
{
return Dequeue(TimeSpan.FromMilliseconds(tmo));
}
public virtual T Dequeue(TimeSpan wait)
{
T res = null;
if (!Dequeue(wait, ref res))
return null;
return res;
}
public bool Dequeue(int timeout, ref T res)
{
return Dequeue(TimeSpan.FromMilliseconds(timeout), ref res);
}
public bool Dequeue(TimeSpan wait, ref T res)
{
if (!m_s.WaitOne(wait))
return false;
lock (m_syncRoot)
{
if (m_highQueue.Count > 0)
res = m_highQueue.Dequeue();
else
res = m_lowQueue.Dequeue();
if (m_highQueue.Count == 0 && m_lowQueue.Count == 0)
return true;
try
{
m_s.Release();
}
catch
{
}
return true;
}
}
public virtual void Clear()
{
lock (m_syncRoot)
{
// Make sure sem count is 0
m_s.WaitOne(0);
m_lowQueue.Clear();
m_highQueue.Clear();
}
}
}
} }

View File

@ -694,7 +694,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
case WearableType.Shape: case WearableType.Shape:
case WearableType.Skin: case WearableType.Skin:
//case WearableType.Underpants: //case WearableType.Underpants:
TryAndRepair((WearableType)i, invService, userID, appearance); TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance);
resetwearable = true; resetwearable = true;
m_log.Warn("[AVFACTORY]: UUID.Zero Wearables, passing fake values."); m_log.Warn("[AVFACTORY]: UUID.Zero Wearables, passing fake values.");
resetwearable = true; resetwearable = true;
@ -714,7 +714,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
case WearableType.Shape: case WearableType.Shape:
case WearableType.Skin: case WearableType.Skin:
//case WearableType.Underpants: //case WearableType.Underpants:
TryAndRepair((WearableType)i, invService, userID, appearance); TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance);
m_log.WarnFormat("[AVFACTORY]: {0} Default Wearables, passing existing values.", (WearableType)i); m_log.WarnFormat("[AVFACTORY]: {0} Default Wearables, passing existing values.", (WearableType)i);
resetwearable = true; resetwearable = true;
@ -730,6 +730,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
if (baseItem != null) if (baseItem != null)
{ {
appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID); appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID);
int unmodifiedWearableIndexForClosure = i;
m_scene.AssetService.Get(baseItem.AssetID.ToString(), this,
delegate(string x, object y, AssetBase z)
{
if (z == null)
{
TryAndRepairBrokenWearable(
(WearableType)unmodifiedWearableIndexForClosure, invService,
userID, appearance);
}
});
} }
else else
{ {
@ -737,7 +748,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
"[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default",
appearance.Wearables[i][j].ItemID, (WearableType)i); appearance.Wearables[i][j].ItemID, (WearableType)i);
TryAndRepair((WearableType)i, invService, userID, appearance); TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance);
resetwearable = true; resetwearable = true;
} }
@ -749,7 +760,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{ {
m_log.WarnFormat("[AVFACTORY]: {0} Eyes are Null, passing existing values.", (WearableType.Eyes)); m_log.WarnFormat("[AVFACTORY]: {0} Eyes are Null, passing existing values.", (WearableType.Eyes));
TryAndRepair(WearableType.Eyes, invService, userID, appearance); TryAndRepairBrokenWearable(WearableType.Eyes, invService, userID, appearance);
resetwearable = true; resetwearable = true;
} }
else else
@ -759,7 +770,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
m_log.WarnFormat("[AVFACTORY]: Eyes are UUID.Zero are broken, {0} {1}", m_log.WarnFormat("[AVFACTORY]: Eyes are UUID.Zero are broken, {0} {1}",
appearance.Wearables[(int) WearableType.Eyes][0].ItemID, appearance.Wearables[(int) WearableType.Eyes][0].ItemID,
appearance.Wearables[(int) WearableType.Eyes][0].AssetID); appearance.Wearables[(int) WearableType.Eyes][0].AssetID);
TryAndRepair(WearableType.Eyes, invService, userID, appearance); TryAndRepairBrokenWearable(WearableType.Eyes, invService, userID, appearance);
resetwearable = true; resetwearable = true;
} }
@ -770,7 +781,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{ {
m_log.WarnFormat("[AVFACTORY]: {0} shape is Null, passing existing values.", (WearableType.Shape)); m_log.WarnFormat("[AVFACTORY]: {0} shape is Null, passing existing values.", (WearableType.Shape));
TryAndRepair(WearableType.Shape, invService, userID, appearance); TryAndRepairBrokenWearable(WearableType.Shape, invService, userID, appearance);
resetwearable = true; resetwearable = true;
} }
else else
@ -780,7 +791,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
m_log.WarnFormat("[AVFACTORY]: Shape is UUID.Zero and broken, {0} {1}", m_log.WarnFormat("[AVFACTORY]: Shape is UUID.Zero and broken, {0} {1}",
appearance.Wearables[(int)WearableType.Shape][0].ItemID, appearance.Wearables[(int)WearableType.Shape][0].ItemID,
appearance.Wearables[(int)WearableType.Shape][0].AssetID); appearance.Wearables[(int)WearableType.Shape][0].AssetID);
TryAndRepair(WearableType.Shape, invService, userID, appearance); TryAndRepairBrokenWearable(WearableType.Shape, invService, userID, appearance);
resetwearable = true; resetwearable = true;
} }
@ -791,7 +802,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{ {
m_log.WarnFormat("[AVFACTORY]: {0} Hair is Null, passing existing values.", (WearableType.Hair)); m_log.WarnFormat("[AVFACTORY]: {0} Hair is Null, passing existing values.", (WearableType.Hair));
TryAndRepair(WearableType.Hair, invService, userID, appearance); TryAndRepairBrokenWearable(WearableType.Hair, invService, userID, appearance);
resetwearable = true; resetwearable = true;
} }
else else
@ -801,7 +812,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
m_log.WarnFormat("[AVFACTORY]: Hair is UUID.Zero and broken, {0} {1}", m_log.WarnFormat("[AVFACTORY]: Hair is UUID.Zero and broken, {0} {1}",
appearance.Wearables[(int)WearableType.Hair][0].ItemID, appearance.Wearables[(int)WearableType.Hair][0].ItemID,
appearance.Wearables[(int)WearableType.Hair][0].AssetID); appearance.Wearables[(int)WearableType.Hair][0].AssetID);
TryAndRepair(WearableType.Hair, invService, userID, appearance); TryAndRepairBrokenWearable(WearableType.Hair, invService, userID, appearance);
resetwearable = true; resetwearable = true;
} }
@ -812,7 +823,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{ {
m_log.WarnFormat("[AVFACTORY]: {0} Skin is Null, passing existing values.", (WearableType.Skin)); m_log.WarnFormat("[AVFACTORY]: {0} Skin is Null, passing existing values.", (WearableType.Skin));
TryAndRepair(WearableType.Skin, invService, userID, appearance); TryAndRepairBrokenWearable(WearableType.Skin, invService, userID, appearance);
resetwearable = true; resetwearable = true;
} }
else else
@ -822,7 +833,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
m_log.WarnFormat("[AVFACTORY]: Skin is UUID.Zero and broken, {0} {1}", m_log.WarnFormat("[AVFACTORY]: Skin is UUID.Zero and broken, {0} {1}",
appearance.Wearables[(int)WearableType.Skin][0].ItemID, appearance.Wearables[(int)WearableType.Skin][0].ItemID,
appearance.Wearables[(int)WearableType.Skin][0].AssetID); appearance.Wearables[(int)WearableType.Skin][0].AssetID);
TryAndRepair(WearableType.Skin, invService, userID, appearance); TryAndRepairBrokenWearable(WearableType.Skin, invService, userID, appearance);
resetwearable = true; resetwearable = true;
} }
@ -844,7 +855,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID);
} }
} }
private void TryAndRepair(WearableType type, IInventoryService invService, UUID userID,AvatarAppearance appearance) private void TryAndRepairBrokenWearable(WearableType type, IInventoryService invService, UUID userID,AvatarAppearance appearance)
{ {
UUID defaultwearable = GetDefaultItem(type); UUID defaultwearable = GetDefaultItem(type);
if (defaultwearable != UUID.Zero) if (defaultwearable != UUID.Zero)

View File

@ -2952,6 +2952,13 @@ namespace OpenSim.Region.Framework.Scenes
SubscribeToClientEvents(client); SubscribeToClientEvents(client);
sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
if (cof == null)
sp.COF = UUID.Zero;
else
sp.COF = cof.ID;
m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF);
m_eventManager.TriggerOnNewPresence(sp); m_eventManager.TriggerOnNewPresence(sp);
sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;

View File

@ -441,6 +441,8 @@ namespace OpenSim.Region.Framework.Scenes
get { return (IClientCore)ControllingClient; } get { return (IClientCore)ControllingClient; }
} }
public UUID COF { get; set; }
// public Vector3 ParentPosition { get; set; } // public Vector3 ParentPosition { get; set; }
/// <summary> /// <summary>

View File

@ -4678,7 +4678,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID av = new UUID(); UUID av = new UUID();
if (!UUID.TryParse(agent,out av)) if (!UUID.TryParse(agent,out av))
{ {
//LSLError("First parameter to llDialog needs to be a key");
return; return;
} }
@ -7175,20 +7174,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
if (buttons.Length > 12) if (buttons.Length > 12)
{ {
LSLError("No more than 12 buttons can be shown"); ShoutError("button list too long, must be 12 or fewer entries");
return;
} }
string[] buts = new string[buttons.Length]; int length = buttons.Length;
for (int i = 0; i < buttons.Length; i++) if (length > 12)
length = 12;
string[] buts = new string[length];
for (int i = 0; i < length; i++)
{ {
if (buttons.Data[i].ToString() == String.Empty) if (buttons.Data[i].ToString() == String.Empty)
{ {
LSLError("button label cannot be blank"); ShoutError("button label cannot be blank");
return; return;
} }
if (buttons.Data[i].ToString().Length > 24) if (buttons.Data[i].ToString().Length > 24)
{ {
llWhisper(ScriptBaseClass.DEBUG_CHANNEL, "button label cannot be longer than 24 characters"); ShoutError("button label cannot be longer than 24 characters");
return; return;
} }
buts[i] = buttons.Data[i].ToString(); buts[i] = buttons.Data[i].ToString();

View File

@ -1607,9 +1607,10 @@
<Reference name="System.Drawing"/> <Reference name="System.Drawing"/>
<Reference name="System.Xml"/> <Reference name="System.Xml"/>
<Reference name="System.Web"/> <Reference name="System.Web"/>
<Reference name="OpenMetaverse" path="../../../../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../../../../bin/"/> <Reference name="OpenMetaverseTypes" path="../../../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../../../bin/"/> <Reference name="OpenMetaverse.StructuredData" path="../../../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../../../bin/"/>
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Capabilities"/> <Reference name="OpenSim.Capabilities"/>
<Reference name="OpenSim.Capabilities.Handlers"/> <Reference name="OpenSim.Capabilities.Handlers"/>