aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2013-02-06 04:03:32 +0100
committerMelanie2013-02-06 04:03:32 +0100
commit598f891d703593bde4b96472b5d1b1ce6aaf4c74 (patch)
treeca8d7bebec807f9cdf0cc81a353f3b685b6ccb9c /OpenSim/Region
parentMake scripts shout a error but not stop when button count is overrun on llDialog (diff)
downloadopensim-SC_OLD-598f891d703593bde4b96472b5d1b1ce6aaf4c74.zip
opensim-SC_OLD-598f891d703593bde4b96472b5d1b1ce6aaf4c74.tar.gz
opensim-SC_OLD-598f891d703593bde4b96472b5d1b1ce6aaf4c74.tar.bz2
opensim-SC_OLD-598f891d703593bde4b96472b5d1b1ce6aaf4c74.tar.xz
Move SoubleQueu to Util. Change HTTP inv to prioritize COF. Determine COF for SP
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs77
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs108
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs2
4 files changed, 79 insertions, 115 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index 04cd474..a823dd8 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -39,10 +39,13 @@ using OpenSim.Framework.Servers;
39using OpenSim.Framework.Servers.HttpServer; 39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Framework.Capabilities;
42using OpenSim.Services.Interfaces; 43using OpenSim.Services.Interfaces;
43using Caps = OpenSim.Framework.Capabilities.Caps; 44using Caps = OpenSim.Framework.Capabilities.Caps;
44using OpenSim.Capabilities.Handlers; 45using OpenSim.Capabilities.Handlers;
45using OpenSim.Framework.Monitoring; 46using OpenSim.Framework.Monitoring;
47using OpenMetaverse;
48using OpenMetaverse.StructuredData;
46 49
47namespace OpenSim.Region.ClientStack.Linden 50namespace OpenSim.Region.ClientStack.Linden
48{ 51{
@@ -52,11 +55,13 @@ namespace OpenSim.Region.ClientStack.Linden
52 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")] 55 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")]
53 public class WebFetchInvDescModule : INonSharedRegionModule 56 public class WebFetchInvDescModule : INonSharedRegionModule
54 { 57 {
55 struct aPollRequest 58 class aPollRequest
56 { 59 {
57 public PollServiceInventoryEventArgs thepoll; 60 public PollServiceInventoryEventArgs thepoll;
58 public UUID reqID; 61 public UUID reqID;
59 public Hashtable request; 62 public Hashtable request;
63 public ScenePresence presence;
64 public List<UUID> folders;
60 } 65 }
61 66
62 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -71,8 +76,8 @@ namespace OpenSim.Region.ClientStack.Linden
71 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); 76 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
72 private static Thread[] m_workerThreads = null; 77 private static Thread[] m_workerThreads = null;
73 78
74 private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue = 79 private static DoubleQueue<aPollRequest> m_queue =
75 new OpenMetaverse.BlockingQueue<aPollRequest>(); 80 new DoubleQueue<aPollRequest>();
76 81
77 #region ISharedRegionModule Members 82 #region ISharedRegionModule Members
78 83
@@ -143,12 +148,18 @@ namespace OpenSim.Region.ClientStack.Linden
143 148
144 private class PollServiceInventoryEventArgs : PollServiceEventArgs 149 private class PollServiceInventoryEventArgs : PollServiceEventArgs
145 { 150 {
151 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
152
146 private Dictionary<UUID, Hashtable> responses = 153 private Dictionary<UUID, Hashtable> responses =
147 new Dictionary<UUID, Hashtable>(); 154 new Dictionary<UUID, Hashtable>();
148 155
149 public PollServiceInventoryEventArgs(UUID pId) : 156 private Scene m_scene;
157
158 public PollServiceInventoryEventArgs(Scene scene, UUID pId) :
150 base(null, null, null, null, pId, int.MaxValue) 159 base(null, null, null, null, pId, int.MaxValue)
151 { 160 {
161 m_scene = scene;
162
152 HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; 163 HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); };
153 GetEvents = (x, y) => 164 GetEvents = (x, y) =>
154 { 165 {
@@ -167,12 +178,64 @@ namespace OpenSim.Region.ClientStack.Linden
167 178
168 Request = (x, y) => 179 Request = (x, y) =>
169 { 180 {
181 ScenePresence sp = m_scene.GetScenePresence(Id);
182 if (sp == null)
183 {
184 m_log.ErrorFormat("[INVENTORY]: Unable to find ScenePresence for {0}", Id);
185 return;
186 }
187
170 aPollRequest reqinfo = new aPollRequest(); 188 aPollRequest reqinfo = new aPollRequest();
171 reqinfo.thepoll = this; 189 reqinfo.thepoll = this;
172 reqinfo.reqID = x; 190 reqinfo.reqID = x;
173 reqinfo.request = y; 191 reqinfo.request = y;
192 reqinfo.presence = sp;
193 reqinfo.folders = new List<UUID>();
194
195 // Decode the request here
196 string request = y["body"].ToString();
197
198 request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>");
199
200 request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>");
201 request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>");
202
203 Hashtable hash = new Hashtable();
204 try
205 {
206 hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
207 }
208 catch (LLSD.LLSDParseException e)
209 {
210 m_log.ErrorFormat("[INVENTORY]: Fetch error: {0}{1}" + e.Message, e.StackTrace);
211 m_log.Error("Request: " + request);
212 return;
213 }
214
215 ArrayList foldersrequested = (ArrayList)hash["folders"];
216
217 bool highPriority = false;
218
219 for (int i = 0; i < foldersrequested.Count; i++)
220 {
221 Hashtable inventoryhash = (Hashtable)foldersrequested[i];
222 string folder = inventoryhash["folder_id"].ToString();
223 UUID folderID;
224 if (UUID.TryParse(folder, out folderID))
225 {
226 if (!reqinfo.folders.Contains(folderID))
227 {
228 if (sp.COF != UUID.Zero && sp.COF == folderID)
229 highPriority = true;
230 reqinfo.folders.Add(folderID);
231 }
232 }
233 }
174 234
175 m_queue.Enqueue(reqinfo); 235 if (highPriority)
236 m_queue.EnqueueHigh(reqinfo);
237 else
238 m_queue.EnqueueLow(reqinfo);
176 }; 239 };
177 240
178 NoEvents = (x, y) => 241 NoEvents = (x, y) =>
@@ -208,7 +271,7 @@ namespace OpenSim.Region.ClientStack.Linden
208 response["reusecontext"] = false; 271 response["reusecontext"] = false;
209 272
210 response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest( 273 response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(
211 requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); 274 requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null);
212 275
213 lock (responses) 276 lock (responses)
214 responses[requestID] = response; 277 responses[requestID] = response;
@@ -220,7 +283,7 @@ namespace OpenSim.Region.ClientStack.Linden
220 string capUrl = "/CAPS/" + UUID.Random() + "/"; 283 string capUrl = "/CAPS/" + UUID.Random() + "/";
221 284
222 // Register this as a poll service 285 // Register this as a poll service
223 PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); 286 PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(m_scene, agentID);
224 287
225 args.Type = PollServiceEventArgs.EventType.Inventory; 288 args.Type = PollServiceEventArgs.EventType.Inventory;
226 MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); 289 MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args);
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 6c72edc..d49f1f7 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1903,112 +1903,4 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1903 } 1903 }
1904 } 1904 }
1905 } 1905 }
1906
1907 internal class DoubleQueue<T> where T:class
1908 {
1909 private Queue<T> m_lowQueue = new Queue<T>();
1910 private Queue<T> m_highQueue = new Queue<T>();
1911
1912 private object m_syncRoot = new object();
1913 private Semaphore m_s = new Semaphore(0, 1);
1914
1915 public DoubleQueue()
1916 {
1917 }
1918
1919 public virtual int Count
1920 {
1921 get { return m_highQueue.Count + m_lowQueue.Count; }
1922 }
1923
1924 public virtual void Enqueue(T data)
1925 {
1926 Enqueue(m_lowQueue, data);
1927 }
1928
1929 public virtual void EnqueueLow(T data)
1930 {
1931 Enqueue(m_lowQueue, data);
1932 }
1933
1934 public virtual void EnqueueHigh(T data)
1935 {
1936 Enqueue(m_highQueue, data);
1937 }
1938
1939 private void Enqueue(Queue<T> q, T data)
1940 {
1941 lock (m_syncRoot)
1942 {
1943 m_lowQueue.Enqueue(data);
1944 m_s.WaitOne(0);
1945 m_s.Release();
1946 }
1947 }
1948
1949 public virtual T Dequeue()
1950 {
1951 return Dequeue(Timeout.Infinite);
1952 }
1953
1954 public virtual T Dequeue(int tmo)
1955 {
1956 return Dequeue(TimeSpan.FromMilliseconds(tmo));
1957 }
1958
1959 public virtual T Dequeue(TimeSpan wait)
1960 {
1961 T res = null;
1962
1963 if (!Dequeue(wait, ref res))
1964 return null;
1965
1966 return res;
1967 }
1968
1969 public bool Dequeue(int timeout, ref T res)
1970 {
1971 return Dequeue(TimeSpan.FromMilliseconds(timeout), ref res);
1972 }
1973
1974 public bool Dequeue(TimeSpan wait, ref T res)
1975 {
1976 if (!m_s.WaitOne(wait))
1977 return false;
1978
1979 lock (m_syncRoot)
1980 {
1981 if (m_highQueue.Count > 0)
1982 res = m_highQueue.Dequeue();
1983 else
1984 res = m_lowQueue.Dequeue();
1985
1986 if (m_highQueue.Count == 0 && m_lowQueue.Count == 0)
1987 return true;
1988
1989 try
1990 {
1991 m_s.Release();
1992 }
1993 catch
1994 {
1995 }
1996
1997 return true;
1998 }
1999 }
2000
2001 public virtual void Clear()
2002 {
2003
2004 lock (m_syncRoot)
2005 {
2006 // Make sure sem count is 0
2007 m_s.WaitOne(0);
2008
2009 m_lowQueue.Clear();
2010 m_highQueue.Clear();
2011 }
2012 }
2013 }
2014} 1906}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c7a38f7..e58aadc 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2970,6 +2970,13 @@ namespace OpenSim.Region.Framework.Scenes
2970 SubscribeToClientEvents(client); 2970 SubscribeToClientEvents(client);
2971 2971
2972 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); 2972 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
2973 InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
2974 if (cof == null)
2975 sp.COF = UUID.Zero;
2976 else
2977 sp.COF = cof.ID;
2978
2979 m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF);
2973 m_eventManager.TriggerOnNewPresence(sp); 2980 m_eventManager.TriggerOnNewPresence(sp);
2974 2981
2975 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; 2982 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 471caa2..91f9c0b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -443,6 +443,8 @@ namespace OpenSim.Region.Framework.Scenes
443 get { return (IClientCore)ControllingClient; } 443 get { return (IClientCore)ControllingClient; }
444 } 444 }
445 445
446 public UUID COF { get; set; }
447
446// public Vector3 ParentPosition { get; set; } 448// public Vector3 ParentPosition { get; set; }
447 449
448 /// <summary> 450 /// <summary>