diff options
author | UbitUmarov | 2016-07-30 04:31:26 +0100 |
---|---|---|
committer | UbitUmarov | 2016-07-30 04:31:26 +0100 |
commit | 22b1b915991eb507399ba7d6f5bcb31464156115 (patch) | |
tree | 37db37e0b2cec4bf3c6f621c5f4ee03e9eb507eb | |
parent | Merge branch 'master' into httptests (diff) | |
parent | fix cAgent.CrossingFlags (diff) | |
download | opensim-SC-22b1b915991eb507399ba7d6f5bcb31464156115.zip opensim-SC-22b1b915991eb507399ba7d6f5bcb31464156115.tar.gz opensim-SC-22b1b915991eb507399ba7d6f5bcb31464156115.tar.bz2 opensim-SC-22b1b915991eb507399ba7d6f5bcb31464156115.tar.xz |
Merge branch 'master' into httptests
3 files changed, 102 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs index 4dc9033..ffe3fab 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
38 | { | 38 | { |
39 | public class RegionInfoCache | 39 | public class RegionInfoCache |
40 | { | 40 | { |
41 | private const double CACHE_EXPIRATION_SECONDS = 120; // 2 minutes opensim regions change a lot | 41 | private const float CACHE_EXPIRATION_SECONDS = 120; // 2 minutes opensim regions change a lot |
42 | 42 | ||
43 | // private static readonly ILog m_log = | 43 | // private static readonly ILog m_log = |
44 | // LogManager.GetLogger( | 44 | // LogManager.GetLogger( |
@@ -54,10 +54,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
54 | public void Cache(GridRegion rinfo) | 54 | public void Cache(GridRegion rinfo) |
55 | { | 55 | { |
56 | if (rinfo != null) | 56 | if (rinfo != null) |
57 | this.Cache(rinfo.ScopeID,rinfo.RegionID,rinfo); | 57 | this.Cache(rinfo.ScopeID, rinfo); |
58 | } | 58 | } |
59 | 59 | ||
60 | public void Cache(UUID scopeID, UUID regionID, GridRegion rinfo) | 60 | public void Cache(UUID scopeID, GridRegion rinfo) |
61 | { | 61 | { |
62 | // for now, do not cache negative results; this is because | 62 | // for now, do not cache negative results; this is because |
63 | // we need to figure out how to handle regions coming online | 63 | // we need to figure out how to handle regions coming online |
@@ -68,6 +68,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
68 | m_Cache.AddOrUpdate(scopeID, rinfo, CACHE_EXPIRATION_SECONDS); | 68 | m_Cache.AddOrUpdate(scopeID, rinfo, CACHE_EXPIRATION_SECONDS); |
69 | } | 69 | } |
70 | 70 | ||
71 | public void Cache(UUID scopeID, GridRegion rinfo, float expireSeconds) | ||
72 | { | ||
73 | // for now, do not cache negative results; this is because | ||
74 | // we need to figure out how to handle regions coming online | ||
75 | // in a timely way | ||
76 | if (rinfo == null) | ||
77 | return; | ||
78 | |||
79 | m_Cache.AddOrUpdate(scopeID, rinfo, expireSeconds); | ||
80 | } | ||
81 | |||
71 | public GridRegion Get(UUID scopeID, UUID regionID, out bool inCache) | 82 | public GridRegion Get(UUID scopeID, UUID regionID, out bool inCache) |
72 | { | 83 | { |
73 | inCache = false; | 84 | inCache = false; |
@@ -109,6 +120,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
109 | 120 | ||
110 | return null; | 121 | return null; |
111 | } | 122 | } |
123 | |||
124 | public GridRegion Get(UUID scopeID, int x, int y, out bool inCache) | ||
125 | { | ||
126 | inCache = false; | ||
127 | |||
128 | GridRegion rinfo = null; | ||
129 | if (m_Cache.TryGetValue(scopeID, x, y, out rinfo)) | ||
130 | { | ||
131 | inCache = true; | ||
132 | return rinfo; | ||
133 | } | ||
134 | |||
135 | return null; | ||
136 | } | ||
137 | |||
112 | } | 138 | } |
113 | 139 | ||
114 | 140 | ||
@@ -222,8 +248,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
222 | 248 | ||
223 | public sealed class RegionsExpiringCache | 249 | public sealed class RegionsExpiringCache |
224 | { | 250 | { |
225 | const double CACHE_PURGE_HZ = 60; | 251 | const double CACHE_PURGE_HZ = 60; // seconds |
226 | const int MAX_LOCK_WAIT = 5000; // milliseconds | 252 | const int MAX_LOCK_WAIT = 10000; // milliseconds |
227 | 253 | ||
228 | /// <summary>For thread safety</summary> | 254 | /// <summary>For thread safety</summary> |
229 | object syncRoot = new object(); | 255 | object syncRoot = new object(); |
@@ -240,7 +266,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
240 | timer.Start(); | 266 | timer.Start(); |
241 | } | 267 | } |
242 | 268 | ||
243 | public bool Add(UUID scope, GridRegion region, double expirationSeconds) | 269 | public bool Add(UUID scope, GridRegion region, float expirationSeconds) |
244 | { | 270 | { |
245 | if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT)) | 271 | if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT)) |
246 | throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms"); | 272 | throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms"); |
@@ -269,7 +295,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
269 | finally { Monitor.Exit(syncRoot);} | 295 | finally { Monitor.Exit(syncRoot);} |
270 | } | 296 | } |
271 | 297 | ||
272 | public bool AddOrUpdate(UUID scope, GridRegion region, double expirationSeconds) | 298 | public bool AddOrUpdate(UUID scope, GridRegion region, float expirationSeconds) |
273 | { | 299 | { |
274 | if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT)) | 300 | if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT)) |
275 | throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms"); | 301 | throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms"); |
@@ -463,6 +489,50 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
463 | return false; | 489 | return false; |
464 | } | 490 | } |
465 | 491 | ||
492 | // gets a region that contains world position (x,y) | ||
493 | // hopefull will not take ages | ||
494 | public bool TryGetValue(UUID scope, int x, int y, out GridRegion value) | ||
495 | { | ||
496 | if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT)) | ||
497 | throw new ApplicationException("Lock could not be acquired after " + MAX_LOCK_WAIT + "ms"); | ||
498 | try | ||
499 | { | ||
500 | value = null; | ||
501 | |||
502 | if(timedStorage.Count == 0) | ||
503 | return false; | ||
504 | |||
505 | foreach(KeyValuePair<RegionKey, GridRegion> kvp in timedStorage) | ||
506 | { | ||
507 | if(kvp.Key.ScopeID != scope) | ||
508 | continue; | ||
509 | |||
510 | GridRegion r = kvp.Value; | ||
511 | if(r == null) // ?? | ||
512 | continue; | ||
513 | int test = r.RegionLocX; | ||
514 | if(x < test) | ||
515 | continue; | ||
516 | test += r.RegionSizeX; | ||
517 | if(x >= test) | ||
518 | continue; | ||
519 | test = r.RegionLocY; | ||
520 | if(y < test) | ||
521 | continue; | ||
522 | test += r.RegionSizeY; | ||
523 | if (y < test) | ||
524 | { | ||
525 | value = r; | ||
526 | return true; | ||
527 | } | ||
528 | } | ||
529 | } | ||
530 | finally { Monitor.Exit(syncRoot); } | ||
531 | |||
532 | value = null; | ||
533 | return false; | ||
534 | } | ||
535 | |||
466 | public bool Update(UUID scope, GridRegion region, double expirationSeconds) | 536 | public bool Update(UUID scope, GridRegion region, double expirationSeconds) |
467 | { | 537 | { |
468 | if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT)) | 538 | if (!Monitor.TryEnter(syncRoot, MAX_LOCK_WAIT)) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 9e27abe..6575cfd 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs | |||
@@ -183,7 +183,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
183 | if (rinfo == null) | 183 | if (rinfo == null) |
184 | rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID); | 184 | rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID); |
185 | 185 | ||
186 | m_RegionInfoCache.Cache(scopeID,regionID,rinfo); | 186 | m_RegionInfoCache.Cache(scopeID, rinfo); |
187 | return rinfo; | 187 | return rinfo; |
188 | } | 188 | } |
189 | 189 | ||
@@ -193,46 +193,45 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
193 | // The coordinates are world coords (meters), NOT region units. | 193 | // The coordinates are world coords (meters), NOT region units. |
194 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 194 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
195 | { | 195 | { |
196 | // try in cache by handler first | ||
196 | ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y); | 197 | ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y); |
197 | uint regionX = Util.WorldToRegionLoc((uint)x); | ||
198 | uint regionY = Util.WorldToRegionLoc((uint)y); | ||
199 | 198 | ||
200 | /* this is no longer valid | ||
201 | // Sanity check | ||
202 | if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y)) | ||
203 | { | ||
204 | m_log.WarnFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{0},{1}>, Should Be=<{2},{3}>", | ||
205 | x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY)); | ||
206 | } | ||
207 | */ | ||
208 | bool inCache = false; | 199 | bool inCache = false; |
209 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache); | 200 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache); |
210 | if (inCache) | 201 | if (inCache) |
211 | { | ||
212 | // m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Found region {0} in cache. Pos=<{1},{2}>, RegionHandle={3}", | ||
213 | // (rinfo == null) ? "<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); | ||
214 | return rinfo; | 202 | return rinfo; |
215 | } | 203 | |
204 | // try in cache by slower position next | ||
205 | rinfo = m_RegionInfoCache.Get(scopeID, x, y, out inCache); | ||
206 | if (inCache) | ||
207 | return rinfo; | ||
216 | 208 | ||
217 | rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); | 209 | rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); |
218 | if (rinfo == null) | 210 | if (rinfo == null) |
219 | rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); | 211 | rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); |
220 | 212 | ||
221 | m_RegionInfoCache.Cache(rinfo); | 213 | |
222 | 214 | ||
223 | if (rinfo == null) | 215 | if (rinfo == null) |
216 | { | ||
217 | uint regionX = Util.WorldToRegionLoc((uint)x); | ||
218 | uint regionY = Util.WorldToRegionLoc((uint)y); | ||
224 | m_log.WarnFormat("[REMOTE GRID CONNECTOR]: Requested region {0}-{1} not found", regionX, regionY); | 219 | m_log.WarnFormat("[REMOTE GRID CONNECTOR]: Requested region {0}-{1} not found", regionX, regionY); |
220 | } | ||
225 | else | 221 | else |
222 | { | ||
223 | m_RegionInfoCache.Cache(scopeID, rinfo); | ||
224 | |||
226 | m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}", | 225 | m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}", |
227 | rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); | 226 | rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); |
228 | 227 | } | |
229 | return rinfo; | 228 | return rinfo; |
230 | } | 229 | } |
231 | 230 | ||
232 | public GridRegion GetRegionByName(UUID scopeID, string regionName) | 231 | public GridRegion GetRegionByName(UUID scopeID, string regionName) |
233 | { | 232 | { |
234 | bool inCache = false; | 233 | bool inCache = false; |
235 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionName, out inCache); | 234 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionName, out inCache); |
236 | if (inCache) | 235 | if (inCache) |
237 | return rinfo; | 236 | return rinfo; |
238 | 237 | ||
@@ -241,7 +240,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
241 | rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); | 240 | rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); |
242 | 241 | ||
243 | // can't cache negative results for name lookups | 242 | // can't cache negative results for name lookups |
244 | m_RegionInfoCache.Cache(rinfo); | 243 | m_RegionInfoCache.Cache(scopeID, rinfo); |
245 | return rinfo; | 244 | return rinfo; |
246 | } | 245 | } |
247 | 246 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7c1a7631..c592385 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -4539,7 +4539,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
4539 | if (Scene.AttachmentsModule != null) | 4539 | if (Scene.AttachmentsModule != null) |
4540 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); | 4540 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); |
4541 | 4541 | ||
4542 | cAgent.CrossingFlags = isCrossUpdate ? crossingFlags : (byte)0; | 4542 | if(isCrossUpdate) |
4543 | { | ||
4544 | cAgent.CrossingFlags = crossingFlags; | ||
4545 | cAgent.CrossingFlags |= 1; | ||
4546 | } | ||
4547 | else | ||
4548 | cAgent.CrossingFlags = 0; | ||
4543 | 4549 | ||
4544 | if(isCrossUpdate && haveGroupInformation) | 4550 | if(isCrossUpdate && haveGroupInformation) |
4545 | { | 4551 | { |