diff options
author | CasperW | 2009-11-24 18:02:12 +0100 |
---|---|---|
committer | CasperW | 2009-11-24 18:02:12 +0100 |
commit | d1147136946daf14724183b3191119be44ff8b16 (patch) | |
tree | fd5c056348acdd0ea82f4c797d15bcae3336ee28 /OpenSim/Region/ScriptEngine | |
parent | Swap the locking of m_EventQueue and m_Script to ease locks on script invento... (diff) | |
download | opensim-SC_OLD-d1147136946daf14724183b3191119be44ff8b16.zip opensim-SC_OLD-d1147136946daf14724183b3191119be44ff8b16.tar.gz opensim-SC_OLD-d1147136946daf14724183b3191119be44ff8b16.tar.bz2 opensim-SC_OLD-d1147136946daf14724183b3191119be44ff8b16.tar.xz |
Drop all locking of part.TaskInventory in favour of a ReaderWriterLockSlim lock handler. This gives us:
- Faster prim inventory actions. Multiple threads can read at once.
- Fixes the known prim inventory thread locks
- In the event of a thread lock occurring, it will usually self heal after sixty seconds with an error message in the console
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
3 files changed, 334 insertions, 256 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b549b5c..a94cd46 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -275,40 +275,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
275 | protected UUID InventorySelf() | 275 | protected UUID InventorySelf() |
276 | { | 276 | { |
277 | UUID invItemID = new UUID(); | 277 | UUID invItemID = new UUID(); |
278 | 278 | bool unlock = false; | |
279 | lock (m_host.TaskInventory) | 279 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
280 | { | ||
281 | m_host.TaskInventory.LockItemsForRead(true); | ||
282 | unlock = true; | ||
283 | } | ||
284 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
280 | { | 285 | { |
281 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 286 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) |
282 | { | 287 | { |
283 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 288 | invItemID = inv.Key; |
284 | { | 289 | break; |
285 | invItemID = inv.Key; | ||
286 | break; | ||
287 | } | ||
288 | } | 290 | } |
289 | } | 291 | } |
290 | 292 | if (unlock) | |
293 | { | ||
294 | m_host.TaskInventory.LockItemsForRead(false); | ||
295 | } | ||
291 | return invItemID; | 296 | return invItemID; |
292 | } | 297 | } |
293 | 298 | ||
294 | protected UUID InventoryKey(string name, int type) | 299 | protected UUID InventoryKey(string name, int type) |
295 | { | 300 | { |
296 | m_host.AddScriptLPS(1); | 301 | m_host.AddScriptLPS(1); |
297 | 302 | m_host.TaskInventory.LockItemsForRead(true); | |
298 | lock (m_host.TaskInventory) | 303 | |
304 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
299 | { | 305 | { |
300 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 306 | if (inv.Value.Name == name) |
301 | { | 307 | { |
302 | if (inv.Value.Name == name) | 308 | m_host.TaskInventory.LockItemsForRead(false); |
309 | |||
310 | if (inv.Value.Type != type) | ||
303 | { | 311 | { |
304 | if (inv.Value.Type != type) | 312 | return UUID.Zero; |
305 | return UUID.Zero; | ||
306 | |||
307 | return inv.Value.AssetID; | ||
308 | } | 313 | } |
314 | |||
315 | return inv.Value.AssetID; | ||
309 | } | 316 | } |
310 | } | 317 | } |
311 | 318 | ||
319 | m_host.TaskInventory.LockItemsForRead(false); | ||
312 | return UUID.Zero; | 320 | return UUID.Zero; |
313 | } | 321 | } |
314 | 322 | ||
@@ -316,17 +324,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
316 | { | 324 | { |
317 | m_host.AddScriptLPS(1); | 325 | m_host.AddScriptLPS(1); |
318 | 326 | ||
319 | lock (m_host.TaskInventory) | 327 | |
328 | m_host.TaskInventory.LockItemsForRead(true); | ||
329 | |||
330 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
320 | { | 331 | { |
321 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 332 | if (inv.Value.Name == name) |
322 | { | 333 | { |
323 | if (inv.Value.Name == name) | 334 | m_host.TaskInventory.LockItemsForRead(false); |
324 | { | 335 | return inv.Value.AssetID; |
325 | return inv.Value.AssetID; | ||
326 | } | ||
327 | } | 336 | } |
328 | } | 337 | } |
329 | 338 | ||
339 | m_host.TaskInventory.LockItemsForRead(false); | ||
340 | |||
341 | |||
330 | return UUID.Zero; | 342 | return UUID.Zero; |
331 | } | 343 | } |
332 | 344 | ||
@@ -2537,12 +2549,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2537 | 2549 | ||
2538 | m_host.AddScriptLPS(1); | 2550 | m_host.AddScriptLPS(1); |
2539 | 2551 | ||
2552 | m_host.TaskInventory.LockItemsForRead(true); | ||
2540 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2553 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2541 | 2554 | m_host.TaskInventory.LockItemsForRead(false); | |
2542 | lock (m_host.TaskInventory) | ||
2543 | { | ||
2544 | item = m_host.TaskInventory[invItemID]; | ||
2545 | } | ||
2546 | 2555 | ||
2547 | if (item.PermsGranter == UUID.Zero) | 2556 | if (item.PermsGranter == UUID.Zero) |
2548 | return 0; | 2557 | return 0; |
@@ -2617,6 +2626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2617 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2626 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2618 | return; | 2627 | return; |
2619 | 2628 | ||
2629 | //Clone is thread-safe | ||
2620 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2630 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2621 | 2631 | ||
2622 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2632 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2750,13 +2760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2750 | { | 2760 | { |
2751 | TaskInventoryItem item; | 2761 | TaskInventoryItem item; |
2752 | 2762 | ||
2753 | lock (m_host.TaskInventory) | 2763 | m_host.TaskInventory.LockItemsForRead(true); |
2764 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2754 | { | 2765 | { |
2755 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2766 | m_host.TaskInventory.LockItemsForRead(false); |
2756 | return; | 2767 | return; |
2757 | else | 2768 | } |
2758 | item = m_host.TaskInventory[InventorySelf()]; | 2769 | else |
2770 | { | ||
2771 | item = m_host.TaskInventory[InventorySelf()]; | ||
2759 | } | 2772 | } |
2773 | m_host.TaskInventory.LockItemsForRead(false); | ||
2760 | 2774 | ||
2761 | if (item.PermsGranter != UUID.Zero) | 2775 | if (item.PermsGranter != UUID.Zero) |
2762 | { | 2776 | { |
@@ -2778,13 +2792,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2778 | { | 2792 | { |
2779 | TaskInventoryItem item; | 2793 | TaskInventoryItem item; |
2780 | 2794 | ||
2795 | m_host.TaskInventory.LockItemsForRead(true); | ||
2781 | lock (m_host.TaskInventory) | 2796 | lock (m_host.TaskInventory) |
2782 | { | 2797 | { |
2798 | |||
2783 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2799 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
2800 | { | ||
2801 | m_host.TaskInventory.LockItemsForRead(false); | ||
2784 | return; | 2802 | return; |
2803 | } | ||
2785 | else | 2804 | else |
2805 | { | ||
2786 | item = m_host.TaskInventory[InventorySelf()]; | 2806 | item = m_host.TaskInventory[InventorySelf()]; |
2807 | } | ||
2787 | } | 2808 | } |
2809 | m_host.TaskInventory.LockItemsForRead(false); | ||
2788 | 2810 | ||
2789 | m_host.AddScriptLPS(1); | 2811 | m_host.AddScriptLPS(1); |
2790 | 2812 | ||
@@ -2821,14 +2843,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2821 | 2843 | ||
2822 | TaskInventoryItem item; | 2844 | TaskInventoryItem item; |
2823 | 2845 | ||
2824 | lock (m_host.TaskInventory) | 2846 | m_host.TaskInventory.LockItemsForRead(true); |
2847 | |||
2848 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2825 | { | 2849 | { |
2826 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2850 | m_host.TaskInventory.LockItemsForRead(false); |
2827 | return; | 2851 | return; |
2828 | else | 2852 | } |
2829 | item = m_host.TaskInventory[InventorySelf()]; | 2853 | else |
2854 | { | ||
2855 | item = m_host.TaskInventory[InventorySelf()]; | ||
2830 | } | 2856 | } |
2831 | 2857 | ||
2858 | m_host.TaskInventory.LockItemsForRead(false); | ||
2859 | |||
2832 | if (item.PermsGranter != m_host.OwnerID) | 2860 | if (item.PermsGranter != m_host.OwnerID) |
2833 | return; | 2861 | return; |
2834 | 2862 | ||
@@ -2853,13 +2881,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2853 | 2881 | ||
2854 | TaskInventoryItem item; | 2882 | TaskInventoryItem item; |
2855 | 2883 | ||
2856 | lock (m_host.TaskInventory) | 2884 | m_host.TaskInventory.LockItemsForRead(true); |
2885 | |||
2886 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2857 | { | 2887 | { |
2858 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2888 | m_host.TaskInventory.LockItemsForRead(false); |
2859 | return; | 2889 | return; |
2860 | else | 2890 | } |
2861 | item = m_host.TaskInventory[InventorySelf()]; | 2891 | else |
2892 | { | ||
2893 | item = m_host.TaskInventory[InventorySelf()]; | ||
2862 | } | 2894 | } |
2895 | m_host.TaskInventory.LockItemsForRead(false); | ||
2896 | |||
2863 | 2897 | ||
2864 | if (item.PermsGranter != m_host.OwnerID) | 2898 | if (item.PermsGranter != m_host.OwnerID) |
2865 | return; | 2899 | return; |
@@ -3083,14 +3117,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3083 | 3117 | ||
3084 | TaskInventoryItem item; | 3118 | TaskInventoryItem item; |
3085 | 3119 | ||
3086 | lock (m_host.TaskInventory) | 3120 | m_host.TaskInventory.LockItemsForRead(true); |
3121 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3087 | { | 3122 | { |
3088 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3123 | m_host.TaskInventory.LockItemsForRead(false); |
3089 | return; | 3124 | return; |
3090 | else | ||
3091 | item = m_host.TaskInventory[InventorySelf()]; | ||
3092 | } | 3125 | } |
3093 | 3126 | else | |
3127 | { | ||
3128 | item = m_host.TaskInventory[InventorySelf()]; | ||
3129 | } | ||
3130 | m_host.TaskInventory.LockItemsForRead(false); | ||
3094 | if (item.PermsGranter == UUID.Zero) | 3131 | if (item.PermsGranter == UUID.Zero) |
3095 | return; | 3132 | return; |
3096 | 3133 | ||
@@ -3120,13 +3157,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3120 | 3157 | ||
3121 | TaskInventoryItem item; | 3158 | TaskInventoryItem item; |
3122 | 3159 | ||
3123 | lock (m_host.TaskInventory) | 3160 | m_host.TaskInventory.LockItemsForRead(true); |
3161 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3124 | { | 3162 | { |
3125 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3163 | m_host.TaskInventory.LockItemsForRead(false); |
3126 | return; | 3164 | return; |
3127 | else | ||
3128 | item = m_host.TaskInventory[InventorySelf()]; | ||
3129 | } | 3165 | } |
3166 | else | ||
3167 | { | ||
3168 | item = m_host.TaskInventory[InventorySelf()]; | ||
3169 | } | ||
3170 | m_host.TaskInventory.LockItemsForRead(false); | ||
3171 | |||
3130 | 3172 | ||
3131 | if (item.PermsGranter == UUID.Zero) | 3173 | if (item.PermsGranter == UUID.Zero) |
3132 | return; | 3174 | return; |
@@ -3199,10 +3241,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3199 | 3241 | ||
3200 | TaskInventoryItem item; | 3242 | TaskInventoryItem item; |
3201 | 3243 | ||
3202 | lock (m_host.TaskInventory) | 3244 | |
3245 | m_host.TaskInventory.LockItemsForRead(true); | ||
3246 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3247 | { | ||
3248 | m_host.TaskInventory.LockItemsForRead(false); | ||
3249 | return; | ||
3250 | } | ||
3251 | else | ||
3203 | { | 3252 | { |
3204 | item = m_host.TaskInventory[invItemID]; | 3253 | item = m_host.TaskInventory[invItemID]; |
3205 | } | 3254 | } |
3255 | m_host.TaskInventory.LockItemsForRead(false); | ||
3206 | 3256 | ||
3207 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3257 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3208 | { | 3258 | { |
@@ -3234,11 +3284,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3234 | 3284 | ||
3235 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3285 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3236 | { | 3286 | { |
3237 | lock (m_host.TaskInventory) | 3287 | m_host.TaskInventory.LockItemsForWrite(true); |
3238 | { | 3288 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3239 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3289 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3240 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3290 | m_host.TaskInventory.LockItemsForWrite(false); |
3241 | } | ||
3242 | 3291 | ||
3243 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3292 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3244 | "run_time_permissions", new Object[] { | 3293 | "run_time_permissions", new Object[] { |
@@ -3258,11 +3307,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3258 | 3307 | ||
3259 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3308 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3260 | { | 3309 | { |
3261 | lock (m_host.TaskInventory) | 3310 | m_host.TaskInventory.LockItemsForWrite(true); |
3262 | { | 3311 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3263 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3312 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3264 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3313 | m_host.TaskInventory.LockItemsForWrite(false); |
3265 | } | ||
3266 | 3314 | ||
3267 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3315 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3268 | "run_time_permissions", new Object[] { | 3316 | "run_time_permissions", new Object[] { |
@@ -3283,11 +3331,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3283 | 3331 | ||
3284 | if (!m_waitingForScriptAnswer) | 3332 | if (!m_waitingForScriptAnswer) |
3285 | { | 3333 | { |
3286 | lock (m_host.TaskInventory) | 3334 | m_host.TaskInventory.LockItemsForWrite(true); |
3287 | { | 3335 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3288 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3336 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3289 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3337 | m_host.TaskInventory.LockItemsForWrite(false); |
3290 | } | ||
3291 | 3338 | ||
3292 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3339 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3293 | m_waitingForScriptAnswer=true; | 3340 | m_waitingForScriptAnswer=true; |
@@ -3322,10 +3369,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3322 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3369 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3323 | llReleaseControls(); | 3370 | llReleaseControls(); |
3324 | 3371 | ||
3325 | lock (m_host.TaskInventory) | 3372 | |
3326 | { | 3373 | m_host.TaskInventory.LockItemsForWrite(true); |
3327 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3374 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3328 | } | 3375 | m_host.TaskInventory.LockItemsForWrite(false); |
3376 | |||
3329 | 3377 | ||
3330 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3378 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3331 | "run_time_permissions", new Object[] { | 3379 | "run_time_permissions", new Object[] { |
@@ -3337,16 +3385,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3337 | { | 3385 | { |
3338 | m_host.AddScriptLPS(1); | 3386 | m_host.AddScriptLPS(1); |
3339 | 3387 | ||
3340 | lock (m_host.TaskInventory) | 3388 | m_host.TaskInventory.LockItemsForRead(true); |
3389 | |||
3390 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3341 | { | 3391 | { |
3342 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3392 | if (item.Type == 10 && item.ItemID == m_itemID) |
3343 | { | 3393 | { |
3344 | if (item.Type == 10 && item.ItemID == m_itemID) | 3394 | m_host.TaskInventory.LockItemsForRead(false); |
3345 | { | 3395 | return item.PermsGranter.ToString(); |
3346 | return item.PermsGranter.ToString(); | ||
3347 | } | ||
3348 | } | 3396 | } |
3349 | } | 3397 | } |
3398 | m_host.TaskInventory.LockItemsForRead(false); | ||
3350 | 3399 | ||
3351 | return UUID.Zero.ToString(); | 3400 | return UUID.Zero.ToString(); |
3352 | } | 3401 | } |
@@ -3355,19 +3404,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3355 | { | 3404 | { |
3356 | m_host.AddScriptLPS(1); | 3405 | m_host.AddScriptLPS(1); |
3357 | 3406 | ||
3358 | lock (m_host.TaskInventory) | 3407 | m_host.TaskInventory.LockItemsForRead(true); |
3408 | |||
3409 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3359 | { | 3410 | { |
3360 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3411 | if (item.Type == 10 && item.ItemID == m_itemID) |
3361 | { | 3412 | { |
3362 | if (item.Type == 10 && item.ItemID == m_itemID) | 3413 | int perms = item.PermsMask; |
3363 | { | 3414 | if (m_automaticLinkPermission) |
3364 | int perms = item.PermsMask; | 3415 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3365 | if (m_automaticLinkPermission) | 3416 | m_host.TaskInventory.LockItemsForRead(false); |
3366 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3417 | return perms; |
3367 | return perms; | ||
3368 | } | ||
3369 | } | 3418 | } |
3370 | } | 3419 | } |
3420 | m_host.TaskInventory.LockItemsForRead(false); | ||
3371 | 3421 | ||
3372 | return 0; | 3422 | return 0; |
3373 | } | 3423 | } |
@@ -3400,11 +3450,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3400 | UUID invItemID = InventorySelf(); | 3450 | UUID invItemID = InventorySelf(); |
3401 | 3451 | ||
3402 | TaskInventoryItem item; | 3452 | TaskInventoryItem item; |
3403 | lock (m_host.TaskInventory) | 3453 | m_host.TaskInventory.LockItemsForRead(true); |
3404 | { | 3454 | item = m_host.TaskInventory[invItemID]; |
3405 | item = m_host.TaskInventory[invItemID]; | 3455 | m_host.TaskInventory.LockItemsForRead(false); |
3406 | } | 3456 | |
3407 | |||
3408 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3457 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3409 | && !m_automaticLinkPermission) | 3458 | && !m_automaticLinkPermission) |
3410 | { | 3459 | { |
@@ -3457,16 +3506,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3457 | m_host.AddScriptLPS(1); | 3506 | m_host.AddScriptLPS(1); |
3458 | UUID invItemID = InventorySelf(); | 3507 | UUID invItemID = InventorySelf(); |
3459 | 3508 | ||
3460 | lock (m_host.TaskInventory) | 3509 | m_host.TaskInventory.LockItemsForRead(true); |
3461 | { | ||
3462 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3510 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3463 | && !m_automaticLinkPermission) | 3511 | && !m_automaticLinkPermission) |
3464 | { | 3512 | { |
3465 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3513 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3514 | m_host.TaskInventory.LockItemsForRead(false); | ||
3466 | return; | 3515 | return; |
3467 | } | 3516 | } |
3468 | } | 3517 | m_host.TaskInventory.LockItemsForRead(false); |
3469 | 3518 | ||
3470 | if (linknum < ScriptBaseClass.LINK_THIS) | 3519 | if (linknum < ScriptBaseClass.LINK_THIS) |
3471 | return; | 3520 | return; |
3472 | 3521 | ||
@@ -3635,17 +3684,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3635 | m_host.AddScriptLPS(1); | 3684 | m_host.AddScriptLPS(1); |
3636 | int count = 0; | 3685 | int count = 0; |
3637 | 3686 | ||
3638 | lock (m_host.TaskInventory) | 3687 | m_host.TaskInventory.LockItemsForRead(true); |
3688 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3639 | { | 3689 | { |
3640 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3690 | if (inv.Value.Type == type || type == -1) |
3641 | { | 3691 | { |
3642 | if (inv.Value.Type == type || type == -1) | 3692 | count = count + 1; |
3643 | { | ||
3644 | count = count + 1; | ||
3645 | } | ||
3646 | } | 3693 | } |
3647 | } | 3694 | } |
3648 | 3695 | ||
3696 | m_host.TaskInventory.LockItemsForRead(false); | ||
3649 | return count; | 3697 | return count; |
3650 | } | 3698 | } |
3651 | 3699 | ||
@@ -3654,16 +3702,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3654 | m_host.AddScriptLPS(1); | 3702 | m_host.AddScriptLPS(1); |
3655 | ArrayList keys = new ArrayList(); | 3703 | ArrayList keys = new ArrayList(); |
3656 | 3704 | ||
3657 | lock (m_host.TaskInventory) | 3705 | m_host.TaskInventory.LockItemsForRead(true); |
3706 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3658 | { | 3707 | { |
3659 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3708 | if (inv.Value.Type == type || type == -1) |
3660 | { | 3709 | { |
3661 | if (inv.Value.Type == type || type == -1) | 3710 | keys.Add(inv.Value.Name); |
3662 | { | ||
3663 | keys.Add(inv.Value.Name); | ||
3664 | } | ||
3665 | } | 3711 | } |
3666 | } | 3712 | } |
3713 | m_host.TaskInventory.LockItemsForRead(false); | ||
3667 | 3714 | ||
3668 | if (keys.Count == 0) | 3715 | if (keys.Count == 0) |
3669 | { | 3716 | { |
@@ -3700,20 +3747,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3700 | } | 3747 | } |
3701 | 3748 | ||
3702 | // move the first object found with this inventory name | 3749 | // move the first object found with this inventory name |
3703 | lock (m_host.TaskInventory) | 3750 | m_host.TaskInventory.LockItemsForRead(true); |
3751 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3704 | { | 3752 | { |
3705 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3753 | if (inv.Value.Name == inventory) |
3706 | { | 3754 | { |
3707 | if (inv.Value.Name == inventory) | 3755 | found = true; |
3708 | { | 3756 | objId = inv.Key; |
3709 | found = true; | 3757 | assetType = inv.Value.Type; |
3710 | objId = inv.Key; | 3758 | objName = inv.Value.Name; |
3711 | assetType = inv.Value.Type; | 3759 | break; |
3712 | objName = inv.Value.Name; | ||
3713 | break; | ||
3714 | } | ||
3715 | } | 3760 | } |
3716 | } | 3761 | } |
3762 | m_host.TaskInventory.LockItemsForRead(false); | ||
3717 | 3763 | ||
3718 | if (!found) | 3764 | if (!found) |
3719 | { | 3765 | { |
@@ -3763,20 +3809,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3763 | { | 3809 | { |
3764 | m_host.AddScriptLPS(1); | 3810 | m_host.AddScriptLPS(1); |
3765 | 3811 | ||
3766 | lock (m_host.TaskInventory) | 3812 | m_host.TaskInventory.LockItemsForRead(true); |
3813 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3767 | { | 3814 | { |
3768 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3815 | if (item.Name == name) |
3769 | { | 3816 | { |
3770 | if (item.Name == name) | 3817 | if (item.ItemID == m_itemID) |
3771 | { | 3818 | throw new ScriptDeleteException(); |
3772 | if (item.ItemID == m_itemID) | 3819 | else |
3773 | throw new ScriptDeleteException(); | 3820 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3774 | else | 3821 | |
3775 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 3822 | m_host.TaskInventory.LockItemsForRead(false); |
3776 | return; | 3823 | return; |
3777 | } | ||
3778 | } | 3824 | } |
3779 | } | 3825 | } |
3826 | m_host.TaskInventory.LockItemsForRead(false); | ||
3780 | } | 3827 | } |
3781 | 3828 | ||
3782 | public void llSetText(string text, LSL_Vector color, double alpha) | 3829 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3865,6 +3912,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3865 | { | 3912 | { |
3866 | m_host.AddScriptLPS(1); | 3913 | m_host.AddScriptLPS(1); |
3867 | 3914 | ||
3915 | //Clone is thread safe | ||
3868 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 3916 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3869 | 3917 | ||
3870 | foreach (TaskInventoryItem item in itemDictionary.Values) | 3918 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3955,17 +4003,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3955 | UUID soundId = UUID.Zero; | 4003 | UUID soundId = UUID.Zero; |
3956 | if (!UUID.TryParse(impact_sound, out soundId)) | 4004 | if (!UUID.TryParse(impact_sound, out soundId)) |
3957 | { | 4005 | { |
3958 | lock (m_host.TaskInventory) | 4006 | m_host.TaskInventory.LockItemsForRead(true); |
4007 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3959 | { | 4008 | { |
3960 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4009 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
3961 | { | 4010 | { |
3962 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4011 | soundId = item.AssetID; |
3963 | { | 4012 | break; |
3964 | soundId = item.AssetID; | ||
3965 | break; | ||
3966 | } | ||
3967 | } | 4013 | } |
3968 | } | 4014 | } |
4015 | m_host.TaskInventory.LockItemsForRead(false); | ||
3969 | } | 4016 | } |
3970 | m_host.CollisionSound = soundId; | 4017 | m_host.CollisionSound = soundId; |
3971 | m_host.CollisionSoundVolume = (float)impact_volume; | 4018 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4011,6 +4058,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4011 | UUID partItemID; | 4058 | UUID partItemID; |
4012 | foreach (SceneObjectPart part in parts) | 4059 | foreach (SceneObjectPart part in parts) |
4013 | { | 4060 | { |
4061 | //Clone is thread safe | ||
4014 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4062 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4015 | 4063 | ||
4016 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4064 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4218,17 +4266,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4218 | 4266 | ||
4219 | m_host.AddScriptLPS(1); | 4267 | m_host.AddScriptLPS(1); |
4220 | 4268 | ||
4221 | lock (m_host.TaskInventory) | 4269 | m_host.TaskInventory.LockItemsForRead(true); |
4270 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4222 | { | 4271 | { |
4223 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4272 | if (item.Type == 10 && item.ItemID == m_itemID) |
4224 | { | 4273 | { |
4225 | if (item.Type == 10 && item.ItemID == m_itemID) | 4274 | result = item.Name!=null?item.Name:String.Empty; |
4226 | { | 4275 | break; |
4227 | result = item.Name!=null?item.Name:String.Empty; | ||
4228 | break; | ||
4229 | } | ||
4230 | } | 4276 | } |
4231 | } | 4277 | } |
4278 | m_host.TaskInventory.LockItemsForRead(false); | ||
4232 | 4279 | ||
4233 | return result; | 4280 | return result; |
4234 | } | 4281 | } |
@@ -4486,23 +4533,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4486 | { | 4533 | { |
4487 | m_host.AddScriptLPS(1); | 4534 | m_host.AddScriptLPS(1); |
4488 | 4535 | ||
4489 | lock (m_host.TaskInventory) | 4536 | m_host.TaskInventory.LockItemsForRead(true); |
4537 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4490 | { | 4538 | { |
4491 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4539 | if (inv.Value.Name == name) |
4492 | { | 4540 | { |
4493 | if (inv.Value.Name == name) | 4541 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4494 | { | 4542 | { |
4495 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4543 | m_host.TaskInventory.LockItemsForRead(false); |
4496 | { | 4544 | return inv.Value.AssetID.ToString(); |
4497 | return inv.Value.AssetID.ToString(); | 4545 | } |
4498 | } | 4546 | else |
4499 | else | 4547 | { |
4500 | { | 4548 | m_host.TaskInventory.LockItemsForRead(false); |
4501 | return UUID.Zero.ToString(); | 4549 | return UUID.Zero.ToString(); |
4502 | } | ||
4503 | } | 4550 | } |
4504 | } | 4551 | } |
4505 | } | 4552 | } |
4553 | m_host.TaskInventory.LockItemsForRead(false); | ||
4506 | 4554 | ||
4507 | return UUID.Zero.ToString(); | 4555 | return UUID.Zero.ToString(); |
4508 | } | 4556 | } |
@@ -5997,14 +6045,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5997 | 6045 | ||
5998 | protected UUID GetTaskInventoryItem(string name) | 6046 | protected UUID GetTaskInventoryItem(string name) |
5999 | { | 6047 | { |
6000 | lock (m_host.TaskInventory) | 6048 | m_host.TaskInventory.LockItemsForRead(true); |
6049 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6001 | { | 6050 | { |
6002 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6051 | if (inv.Value.Name == name) |
6003 | { | 6052 | { |
6004 | if (inv.Value.Name == name) | 6053 | m_host.TaskInventory.LockItemsForRead(false); |
6005 | return inv.Key; | 6054 | return inv.Key; |
6006 | } | 6055 | } |
6007 | } | 6056 | } |
6057 | m_host.TaskInventory.LockItemsForRead(false); | ||
6008 | 6058 | ||
6009 | return UUID.Zero; | 6059 | return UUID.Zero; |
6010 | } | 6060 | } |
@@ -6315,22 +6365,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6315 | } | 6365 | } |
6316 | 6366 | ||
6317 | // copy the first script found with this inventory name | 6367 | // copy the first script found with this inventory name |
6318 | lock (m_host.TaskInventory) | 6368 | m_host.TaskInventory.LockItemsForRead(true); |
6369 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6319 | { | 6370 | { |
6320 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6371 | if (inv.Value.Name == name) |
6321 | { | 6372 | { |
6322 | if (inv.Value.Name == name) | 6373 | // make sure the object is a script |
6374 | if (10 == inv.Value.Type) | ||
6323 | { | 6375 | { |
6324 | // make sure the object is a script | 6376 | found = true; |
6325 | if (10 == inv.Value.Type) | 6377 | srcId = inv.Key; |
6326 | { | 6378 | break; |
6327 | found = true; | ||
6328 | srcId = inv.Key; | ||
6329 | break; | ||
6330 | } | ||
6331 | } | 6379 | } |
6332 | } | 6380 | } |
6333 | } | 6381 | } |
6382 | m_host.TaskInventory.LockItemsForRead(false); | ||
6334 | 6383 | ||
6335 | if (!found) | 6384 | if (!found) |
6336 | { | 6385 | { |
@@ -8133,28 +8182,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8133 | { | 8182 | { |
8134 | m_host.AddScriptLPS(1); | 8183 | m_host.AddScriptLPS(1); |
8135 | 8184 | ||
8136 | lock (m_host.TaskInventory) | 8185 | m_host.TaskInventory.LockItemsForRead(true); |
8186 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8137 | { | 8187 | { |
8138 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8188 | if (inv.Value.Name == item) |
8139 | { | 8189 | { |
8140 | if (inv.Value.Name == item) | 8190 | m_host.TaskInventory.LockItemsForRead(false); |
8191 | switch (mask) | ||
8141 | { | 8192 | { |
8142 | switch (mask) | 8193 | case 0: |
8143 | { | 8194 | return (int)inv.Value.BasePermissions; |
8144 | case 0: | 8195 | case 1: |
8145 | return (int)inv.Value.BasePermissions; | 8196 | return (int)inv.Value.CurrentPermissions; |
8146 | case 1: | 8197 | case 2: |
8147 | return (int)inv.Value.CurrentPermissions; | 8198 | return (int)inv.Value.GroupPermissions; |
8148 | case 2: | 8199 | case 3: |
8149 | return (int)inv.Value.GroupPermissions; | 8200 | return (int)inv.Value.EveryonePermissions; |
8150 | case 3: | 8201 | case 4: |
8151 | return (int)inv.Value.EveryonePermissions; | 8202 | return (int)inv.Value.NextPermissions; |
8152 | case 4: | ||
8153 | return (int)inv.Value.NextPermissions; | ||
8154 | } | ||
8155 | } | 8203 | } |
8156 | } | 8204 | } |
8157 | } | 8205 | } |
8206 | m_host.TaskInventory.LockItemsForRead(false); | ||
8158 | 8207 | ||
8159 | return -1; | 8208 | return -1; |
8160 | } | 8209 | } |
@@ -8169,16 +8218,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8169 | { | 8218 | { |
8170 | m_host.AddScriptLPS(1); | 8219 | m_host.AddScriptLPS(1); |
8171 | 8220 | ||
8172 | lock (m_host.TaskInventory) | 8221 | m_host.TaskInventory.LockItemsForRead(true); |
8222 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8173 | { | 8223 | { |
8174 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8224 | if (inv.Value.Name == item) |
8175 | { | 8225 | { |
8176 | if (inv.Value.Name == item) | 8226 | m_host.TaskInventory.LockItemsForRead(false); |
8177 | { | 8227 | return inv.Value.CreatorID.ToString(); |
8178 | return inv.Value.CreatorID.ToString(); | ||
8179 | } | ||
8180 | } | 8228 | } |
8181 | } | 8229 | } |
8230 | m_host.TaskInventory.LockItemsForRead(false); | ||
8182 | 8231 | ||
8183 | llSay(0, "No item name '" + item + "'"); | 8232 | llSay(0, "No item name '" + item + "'"); |
8184 | 8233 | ||
@@ -8702,16 +8751,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8702 | { | 8751 | { |
8703 | m_host.AddScriptLPS(1); | 8752 | m_host.AddScriptLPS(1); |
8704 | 8753 | ||
8705 | lock (m_host.TaskInventory) | 8754 | m_host.TaskInventory.LockItemsForRead(true); |
8755 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8706 | { | 8756 | { |
8707 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8757 | if (inv.Value.Name == name) |
8708 | { | 8758 | { |
8709 | if (inv.Value.Name == name) | 8759 | m_host.TaskInventory.LockItemsForRead(false); |
8710 | { | 8760 | return inv.Value.Type; |
8711 | return inv.Value.Type; | ||
8712 | } | ||
8713 | } | 8761 | } |
8714 | } | 8762 | } |
8763 | m_host.TaskInventory.LockItemsForRead(false); | ||
8715 | 8764 | ||
8716 | return -1; | 8765 | return -1; |
8717 | } | 8766 | } |
@@ -8742,17 +8791,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8742 | if (invItemID == UUID.Zero) | 8791 | if (invItemID == UUID.Zero) |
8743 | return new LSL_Vector(); | 8792 | return new LSL_Vector(); |
8744 | 8793 | ||
8745 | lock (m_host.TaskInventory) | 8794 | m_host.TaskInventory.LockItemsForRead(true); |
8795 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8746 | { | 8796 | { |
8747 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8797 | m_host.TaskInventory.LockItemsForRead(false); |
8748 | return new LSL_Vector(); | 8798 | return new LSL_Vector(); |
8799 | } | ||
8749 | 8800 | ||
8750 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8801 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8751 | { | 8802 | { |
8752 | ShoutError("No permissions to track the camera"); | 8803 | ShoutError("No permissions to track the camera"); |
8753 | return new LSL_Vector(); | 8804 | m_host.TaskInventory.LockItemsForRead(false); |
8754 | } | 8805 | return new LSL_Vector(); |
8755 | } | 8806 | } |
8807 | m_host.TaskInventory.LockItemsForRead(false); | ||
8756 | 8808 | ||
8757 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8809 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8758 | if (presence != null) | 8810 | if (presence != null) |
@@ -8770,17 +8822,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8770 | if (invItemID == UUID.Zero) | 8822 | if (invItemID == UUID.Zero) |
8771 | return new LSL_Rotation(); | 8823 | return new LSL_Rotation(); |
8772 | 8824 | ||
8773 | lock (m_host.TaskInventory) | 8825 | m_host.TaskInventory.LockItemsForRead(true); |
8826 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8774 | { | 8827 | { |
8775 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8828 | m_host.TaskInventory.LockItemsForRead(false); |
8776 | return new LSL_Rotation(); | 8829 | return new LSL_Rotation(); |
8777 | |||
8778 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8779 | { | ||
8780 | ShoutError("No permissions to track the camera"); | ||
8781 | return new LSL_Rotation(); | ||
8782 | } | ||
8783 | } | 8830 | } |
8831 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8832 | { | ||
8833 | ShoutError("No permissions to track the camera"); | ||
8834 | m_host.TaskInventory.LockItemsForRead(false); | ||
8835 | return new LSL_Rotation(); | ||
8836 | } | ||
8837 | m_host.TaskInventory.LockItemsForRead(false); | ||
8784 | 8838 | ||
8785 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8839 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8786 | if (presence != null) | 8840 | if (presence != null) |
@@ -8930,14 +8984,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8930 | if (objectID == UUID.Zero) return; | 8984 | if (objectID == UUID.Zero) return; |
8931 | 8985 | ||
8932 | UUID agentID; | 8986 | UUID agentID; |
8933 | lock (m_host.TaskInventory) | 8987 | m_host.TaskInventory.LockItemsForRead(true); |
8934 | { | 8988 | // we need the permission first, to know which avatar we want to set the camera for |
8935 | // we need the permission first, to know which avatar we want to set the camera for | 8989 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
8936 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
8937 | 8990 | ||
8938 | if (agentID == UUID.Zero) return; | 8991 | if (agentID == UUID.Zero) |
8939 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 8992 | { |
8993 | m_host.TaskInventory.LockItemsForRead(false); | ||
8994 | return; | ||
8995 | } | ||
8996 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
8997 | { | ||
8998 | m_host.TaskInventory.LockItemsForRead(false); | ||
8999 | return; | ||
8940 | } | 9000 | } |
9001 | m_host.TaskInventory.LockItemsForRead(false); | ||
8941 | 9002 | ||
8942 | ScenePresence presence = World.GetScenePresence(agentID); | 9003 | ScenePresence presence = World.GetScenePresence(agentID); |
8943 | 9004 | ||
@@ -8987,12 +9048,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8987 | 9048 | ||
8988 | // we need the permission first, to know which avatar we want to clear the camera for | 9049 | // we need the permission first, to know which avatar we want to clear the camera for |
8989 | UUID agentID; | 9050 | UUID agentID; |
8990 | lock (m_host.TaskInventory) | 9051 | m_host.TaskInventory.LockItemsForRead(true); |
9052 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9053 | if (agentID == UUID.Zero) | ||
8991 | { | 9054 | { |
8992 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9055 | m_host.TaskInventory.LockItemsForRead(false); |
8993 | if (agentID == UUID.Zero) return; | 9056 | return; |
8994 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
8995 | } | 9057 | } |
9058 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9059 | { | ||
9060 | m_host.TaskInventory.LockItemsForRead(false); | ||
9061 | return; | ||
9062 | } | ||
9063 | m_host.TaskInventory.LockItemsForRead(false); | ||
8996 | 9064 | ||
8997 | ScenePresence presence = World.GetScenePresence(agentID); | 9065 | ScenePresence presence = World.GetScenePresence(agentID); |
8998 | 9066 | ||
@@ -9449,15 +9517,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9449 | 9517 | ||
9450 | internal UUID ScriptByName(string name) | 9518 | internal UUID ScriptByName(string name) |
9451 | { | 9519 | { |
9452 | lock (m_host.TaskInventory) | 9520 | m_host.TaskInventory.LockItemsForRead(true); |
9521 | |||
9522 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9453 | { | 9523 | { |
9454 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9524 | if (item.Type == 10 && item.Name == name) |
9455 | { | 9525 | { |
9456 | if (item.Type == 10 && item.Name == name) | 9526 | m_host.TaskInventory.LockItemsForRead(false); |
9457 | return item.ItemID; | 9527 | return item.ItemID; |
9458 | } | 9528 | } |
9459 | } | 9529 | } |
9460 | 9530 | ||
9531 | m_host.TaskInventory.LockItemsForRead(false); | ||
9532 | |||
9461 | return UUID.Zero; | 9533 | return UUID.Zero; |
9462 | } | 9534 | } |
9463 | 9535 | ||
@@ -9498,6 +9570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9498 | { | 9570 | { |
9499 | m_host.AddScriptLPS(1); | 9571 | m_host.AddScriptLPS(1); |
9500 | 9572 | ||
9573 | //Clone is thread safe | ||
9501 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9574 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9502 | 9575 | ||
9503 | UUID assetID = UUID.Zero; | 9576 | UUID assetID = UUID.Zero; |
@@ -9560,6 +9633,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9560 | { | 9633 | { |
9561 | m_host.AddScriptLPS(1); | 9634 | m_host.AddScriptLPS(1); |
9562 | 9635 | ||
9636 | //Clone is thread safe | ||
9563 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9637 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9564 | 9638 | ||
9565 | UUID assetID = UUID.Zero; | 9639 | UUID assetID = UUID.Zero; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7fdbac8..83322eb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
728 | if (target != null) | 728 | if (target != null) |
729 | { | 729 | { |
730 | UUID animID=UUID.Zero; | 730 | UUID animID=UUID.Zero; |
731 | lock (m_host.TaskInventory) | 731 | m_host.TaskInventory.LockItemsForRead(true); |
732 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
732 | { | 733 | { |
733 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 734 | if (inv.Value.Name == animation) |
734 | { | 735 | { |
735 | if (inv.Value.Name == animation) | 736 | if (inv.Value.Type == (int)AssetType.Animation) |
736 | { | 737 | animID = inv.Value.AssetID; |
737 | if (inv.Value.Type == (int)AssetType.Animation) | 738 | continue; |
738 | animID = inv.Value.AssetID; | ||
739 | continue; | ||
740 | } | ||
741 | } | 739 | } |
742 | } | 740 | } |
741 | m_host.TaskInventory.LockItemsForRead(false); | ||
743 | if (animID == UUID.Zero) | 742 | if (animID == UUID.Zero) |
744 | target.Animator.AddAnimation(animation, m_host.UUID); | 743 | target.Animator.AddAnimation(animation, m_host.UUID); |
745 | else | 744 | else |
@@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
761 | if (target != null) | 760 | if (target != null) |
762 | { | 761 | { |
763 | UUID animID=UUID.Zero; | 762 | UUID animID=UUID.Zero; |
764 | lock (m_host.TaskInventory) | 763 | m_host.TaskInventory.LockItemsForRead(true); |
764 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
765 | { | 765 | { |
766 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 766 | if (inv.Value.Name == animation) |
767 | { | 767 | { |
768 | if (inv.Value.Name == animation) | 768 | if (inv.Value.Type == (int)AssetType.Animation) |
769 | { | 769 | animID = inv.Value.AssetID; |
770 | if (inv.Value.Type == (int)AssetType.Animation) | 770 | continue; |
771 | animID = inv.Value.AssetID; | ||
772 | continue; | ||
773 | } | ||
774 | } | 771 | } |
775 | } | 772 | } |
773 | m_host.TaskInventory.LockItemsForRead(false); | ||
776 | 774 | ||
777 | if (animID == UUID.Zero) | 775 | if (animID == UUID.Zero) |
778 | target.Animator.RemoveAnimation(animation); | 776 | target.Animator.RemoveAnimation(animation); |
@@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1541 | 1539 | ||
1542 | if (!UUID.TryParse(name, out assetID)) | 1540 | if (!UUID.TryParse(name, out assetID)) |
1543 | { | 1541 | { |
1542 | m_host.TaskInventory.LockItemsForRead(true); | ||
1544 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1543 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1545 | { | 1544 | { |
1546 | if (item.Type == 7 && item.Name == name) | 1545 | if (item.Type == 7 && item.Name == name) |
@@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1548 | assetID = item.AssetID; | 1547 | assetID = item.AssetID; |
1549 | } | 1548 | } |
1550 | } | 1549 | } |
1550 | m_host.TaskInventory.LockItemsForRead(false); | ||
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | if (assetID == UUID.Zero) | 1553 | if (assetID == UUID.Zero) |
@@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1594 | 1594 | ||
1595 | if (!UUID.TryParse(name, out assetID)) | 1595 | if (!UUID.TryParse(name, out assetID)) |
1596 | { | 1596 | { |
1597 | m_host.TaskInventory.LockItemsForRead(true); | ||
1597 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1598 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1598 | { | 1599 | { |
1599 | if (item.Type == 7 && item.Name == name) | 1600 | if (item.Type == 7 && item.Name == name) |
@@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1601 | assetID = item.AssetID; | 1602 | assetID = item.AssetID; |
1602 | } | 1603 | } |
1603 | } | 1604 | } |
1605 | m_host.TaskInventory.LockItemsForRead(false); | ||
1604 | } | 1606 | } |
1605 | 1607 | ||
1606 | if (assetID == UUID.Zero) | 1608 | if (assetID == UUID.Zero) |
@@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1651 | 1653 | ||
1652 | if (!UUID.TryParse(name, out assetID)) | 1654 | if (!UUID.TryParse(name, out assetID)) |
1653 | { | 1655 | { |
1656 | m_host.TaskInventory.LockItemsForRead(true); | ||
1654 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1657 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1655 | { | 1658 | { |
1656 | if (item.Type == 7 && item.Name == name) | 1659 | if (item.Type == 7 && item.Name == name) |
@@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1658 | assetID = item.AssetID; | 1661 | assetID = item.AssetID; |
1659 | } | 1662 | } |
1660 | } | 1663 | } |
1664 | m_host.TaskInventory.LockItemsForRead(false); | ||
1661 | } | 1665 | } |
1662 | 1666 | ||
1663 | if (assetID == UUID.Zero) | 1667 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 063d50f..0f4a9ad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -238,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
238 | 238 | ||
239 | if (part != null) | 239 | if (part != null) |
240 | { | 240 | { |
241 | lock (part.TaskInventory) | 241 | part.TaskInventory.LockItemsForRead(true); |
242 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
242 | { | 243 | { |
243 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 244 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
244 | { | ||
245 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
246 | } | ||
247 | } | 245 | } |
246 | part.TaskInventory.LockItemsForRead(false); | ||
248 | } | 247 | } |
249 | 248 | ||
250 | ApiManager am = new ApiManager(); | 249 | ApiManager am = new ApiManager(); |
@@ -429,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
429 | { | 428 | { |
430 | int permsMask; | 429 | int permsMask; |
431 | UUID permsGranter; | 430 | UUID permsGranter; |
432 | lock (part.TaskInventory) | 431 | part.TaskInventory.LockItemsForRead(true); |
432 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
433 | { | 433 | { |
434 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 434 | part.TaskInventory.LockItemsForRead(false); |
435 | return; | 435 | return; |
436 | |||
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | } | 436 | } |
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | part.TaskInventory.LockItemsForRead(false); | ||
440 | 440 | ||
441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
442 | { | 442 | { |