aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/CnmMemoryCache.cs246
-rw-r--r--OpenSim/Framework/CnmSynchronizedCache.cs77
-rw-r--r--OpenSim/Framework/PrimeNumberHelper.cs26
-rw-r--r--OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs68
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs6
-rw-r--r--OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs38
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs36
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs6
11 files changed, 264 insertions, 263 deletions
diff --git a/OpenSim/Framework/CnmMemoryCache.cs b/OpenSim/Framework/CnmMemoryCache.cs
index 77ca10c..db91801 100644
--- a/OpenSim/Framework/CnmMemoryCache.cs
+++ b/OpenSim/Framework/CnmMemoryCache.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Framework
81 /// 30 minutes. 81 /// 30 minutes.
82 /// </para> 82 /// </para>
83 /// </remarks> 83 /// </remarks>
84 public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes( 30.0 ); 84 public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes(30.0);
85 85
86 /// <summary> 86 /// <summary>
87 /// Minimal allowed expiration time. 87 /// Minimal allowed expiration time.
@@ -91,7 +91,7 @@ namespace OpenSim.Framework
91 /// 5 minutes. 91 /// 5 minutes.
92 /// </para> 92 /// </para>
93 /// </remarks> 93 /// </remarks>
94 public static readonly TimeSpan MinExpirationTime = TimeSpan.FromSeconds( 10.0 ); 94 public static readonly TimeSpan MinExpirationTime = TimeSpan.FromSeconds(10.0);
95 95
96 /// <summary> 96 /// <summary>
97 /// Comparer used to compare element keys. 97 /// Comparer used to compare element keys.
@@ -171,7 +171,7 @@ namespace OpenSim.Framework
171 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class. 171 /// Initializes a new instance of the <see cref="CnmMemoryCache{TKey,TValue}"/> class.
172 /// </summary> 172 /// </summary>
173 public CnmMemoryCache() 173 public CnmMemoryCache()
174 : this( DefaultMaxSize ) 174 : this(DefaultMaxSize)
175 { 175 {
176 } 176 }
177 177
@@ -181,8 +181,8 @@ namespace OpenSim.Framework
181 /// <param name="maximalSize"> 181 /// <param name="maximalSize">
182 /// Maximal cache size. 182 /// Maximal cache size.
183 /// </param> 183 /// </param>
184 public CnmMemoryCache( long maximalSize ) 184 public CnmMemoryCache(long maximalSize)
185 : this( maximalSize, DefaultMaxCount ) 185 : this(maximalSize, DefaultMaxCount)
186 { 186 {
187 } 187 }
188 188
@@ -195,8 +195,8 @@ namespace OpenSim.Framework
195 /// <param name="maximalCount"> 195 /// <param name="maximalCount">
196 /// Maximal element count. 196 /// Maximal element count.
197 /// </param> 197 /// </param>
198 public CnmMemoryCache( long maximalSize, int maximalCount ) 198 public CnmMemoryCache(long maximalSize, int maximalCount)
199 : this( maximalSize, maximalCount, DefaultExpirationTime ) 199 : this(maximalSize, maximalCount, DefaultExpirationTime)
200 { 200 {
201 } 201 }
202 202
@@ -212,8 +212,8 @@ namespace OpenSim.Framework
212 /// <param name="expirationTime"> 212 /// <param name="expirationTime">
213 /// Elements expiration time. 213 /// Elements expiration time.
214 /// </param> 214 /// </param>
215 public CnmMemoryCache( long maximalSize, int maximalCount, TimeSpan expirationTime ) 215 public CnmMemoryCache(long maximalSize, int maximalCount, TimeSpan expirationTime)
216 : this( maximalSize, maximalCount, expirationTime, EqualityComparer<TKey>.Default ) 216 : this(maximalSize, maximalCount, expirationTime, EqualityComparer<TKey>.Default)
217 { 217 {
218 } 218 }
219 219
@@ -235,21 +235,21 @@ namespace OpenSim.Framework
235 /// <exception cref="ArgumentNullException"> 235 /// <exception cref="ArgumentNullException">
236 /// <see cref="comparer"/>is <see langword="null"/> reference. 236 /// <see cref="comparer"/>is <see langword="null"/> reference.
237 /// </exception> 237 /// </exception>
238 public CnmMemoryCache( long maximalSize, 238 public CnmMemoryCache(long maximalSize,
239 int maximalCount, 239 int maximalCount,
240 TimeSpan expirationTime, 240 TimeSpan expirationTime,
241 IEqualityComparer<TKey> comparer ) 241 IEqualityComparer<TKey> comparer)
242 { 242 {
243 if( comparer == null ) 243 if (comparer == null)
244 throw new ArgumentNullException( "comparer" ); 244 throw new ArgumentNullException("comparer");
245 245
246 if( expirationTime < MinExpirationTime ) 246 if (expirationTime < MinExpirationTime)
247 expirationTime = MinExpirationTime; 247 expirationTime = MinExpirationTime;
248 if( maximalCount < 8 ) 248 if (maximalCount < 8)
249 maximalCount = 8; 249 maximalCount = 8;
250 if( maximalSize < 8 ) 250 if (maximalSize < 8)
251 maximalSize = 8; 251 maximalSize = 8;
252 if( maximalCount > maximalSize ) 252 if (maximalCount > maximalSize)
253 maximalCount = (int) maximalSize; 253 maximalCount = (int) maximalSize;
254 254
255 Comparer = comparer; 255 Comparer = comparer;
@@ -275,14 +275,14 @@ namespace OpenSim.Framework
275 /// <param name="size"> 275 /// <param name="size">
276 /// The element's size. 276 /// The element's size.
277 /// </param> 277 /// </param>
278 protected virtual void AddToNewGeneration( int bucketIndex, TKey key, TValue value, long size ) 278 protected virtual void AddToNewGeneration(int bucketIndex, TKey key, TValue value, long size)
279 { 279 {
280 // Add to newest generation 280 // Add to newest generation
281 if( !m_newGeneration.Set( bucketIndex, key, value, size ) ) 281 if (!m_newGeneration.Set(bucketIndex, key, value, size))
282 { 282 {
283 // Failed to add new generation 283 // Failed to add new generation
284 RecycleGenerations(); 284 RecycleGenerations();
285 m_newGeneration.Set( bucketIndex, key, value, size ); 285 m_newGeneration.Set(bucketIndex, key, value, size);
286 } 286 }
287 287
288 m_version++; 288 m_version++;
@@ -314,9 +314,9 @@ namespace OpenSim.Framework
314 /// For example: key's hash is 72, bucket count is 5, element's bucket index is 72 % 5 = 2. 314 /// For example: key's hash is 72, bucket count is 5, element's bucket index is 72 % 5 = 2.
315 /// </para> 315 /// </para>
316 /// </remarks> 316 /// </remarks>
317 protected virtual int GetBucketIndex( TKey key ) 317 protected virtual int GetBucketIndex(TKey key)
318 { 318 {
319 return (Comparer.GetHashCode( key ) & 0x7FFFFFFF) % m_generationBucketCount; 319 return (Comparer.GetHashCode(key) & 0x7FFFFFFF) % m_generationBucketCount;
320 } 320 }
321 321
322 /// <summary> 322 /// <summary>
@@ -325,7 +325,7 @@ namespace OpenSim.Framework
325 /// <param name="generation"> 325 /// <param name="generation">
326 /// The generation that is purged. 326 /// The generation that is purged.
327 /// </param> 327 /// </param>
328 protected virtual void PurgeGeneration( IGeneration generation ) 328 protected virtual void PurgeGeneration(IGeneration generation)
329 { 329 {
330 generation.Clear(); 330 generation.Clear();
331 m_version++; 331 m_version++;
@@ -339,7 +339,7 @@ namespace OpenSim.Framework
339 // Do this only one in every m_operationsBetweenTimeChecks 339 // Do this only one in every m_operationsBetweenTimeChecks
340 // Fetching time is using several millisecons - it is better not to do all time. 340 // Fetching time is using several millisecons - it is better not to do all time.
341 m_operationsBetweenTimeChecks--; 341 m_operationsBetweenTimeChecks--;
342 if( m_operationsBetweenTimeChecks <= 0 ) 342 if (m_operationsBetweenTimeChecks <= 0)
343 PurgeExpired(); 343 PurgeExpired();
344 } 344 }
345 345
@@ -355,10 +355,10 @@ namespace OpenSim.Framework
355 m_generationElementCount = MaxCount / 2; 355 m_generationElementCount = MaxCount / 2;
356 356
357 // Buckets need to be prime number to get better spread of hash values 357 // Buckets need to be prime number to get better spread of hash values
358 m_generationBucketCount = PrimeNumberHelper.GetPrime( m_generationElementCount ); 358 m_generationBucketCount = PrimeNumberHelper.GetPrime(m_generationElementCount);
359 359
360 m_newGeneration = new HashGeneration( this ); 360 m_newGeneration = new HashGeneration(this);
361 m_oldGeneration = new HashGeneration( this ); 361 m_oldGeneration = new HashGeneration(this);
362 m_oldGeneration.MakeOld(); 362 m_oldGeneration.MakeOld();
363 } 363 }
364 364
@@ -399,7 +399,7 @@ namespace OpenSim.Framework
399 /// <param name="cache"> 399 /// <param name="cache">
400 /// The cache. 400 /// The cache.
401 /// </param> 401 /// </param>
402 public Enumerator( CnmMemoryCache<TKey, TValue> cache ) 402 public Enumerator(CnmMemoryCache<TKey, TValue> cache)
403 { 403 {
404 m_generationEnumerators[ 0 ] = cache.m_newGeneration.GetEnumerator(); 404 m_generationEnumerators[ 0 ] = cache.m_newGeneration.GetEnumerator();
405 m_generationEnumerators[ 1 ] = cache.m_oldGeneration.GetEnumerator(); 405 m_generationEnumerators[ 1 ] = cache.m_oldGeneration.GetEnumerator();
@@ -420,7 +420,7 @@ namespace OpenSim.Framework
420 { 420 {
421 get 421 get
422 { 422 {
423 if( m_currentEnumerator == -1 || m_currentEnumerator >= m_generationEnumerators.Length ) 423 if (m_currentEnumerator == -1 || m_currentEnumerator >= m_generationEnumerators.Length)
424 throw new InvalidOperationException(); 424 throw new InvalidOperationException();
425 425
426 return m_generationEnumerators[ m_currentEnumerator ].Current; 426 return m_generationEnumerators[ m_currentEnumerator ].Current;
@@ -461,12 +461,12 @@ namespace OpenSim.Framework
461 /// <filterpriority>2</filterpriority> 461 /// <filterpriority>2</filterpriority>
462 public bool MoveNext() 462 public bool MoveNext()
463 { 463 {
464 if( m_currentEnumerator == -1 ) 464 if (m_currentEnumerator == -1)
465 m_currentEnumerator = 0; 465 m_currentEnumerator = 0;
466 466
467 while( m_currentEnumerator < m_generationEnumerators.Length ) 467 while (m_currentEnumerator < m_generationEnumerators.Length)
468 { 468 {
469 if( m_generationEnumerators[ m_currentEnumerator ].MoveNext() ) 469 if (m_generationEnumerators[ m_currentEnumerator ].MoveNext())
470 return true; 470 return true;
471 471
472 m_currentEnumerator++; 472 m_currentEnumerator++;
@@ -484,7 +484,7 @@ namespace OpenSim.Framework
484 /// <filterpriority>2</filterpriority> 484 /// <filterpriority>2</filterpriority>
485 public void Reset() 485 public void Reset()
486 { 486 {
487 foreach( IEnumerator<KeyValuePair<TKey, TValue>> enumerator in m_generationEnumerators ) 487 foreach (IEnumerator<KeyValuePair<TKey, TValue>> enumerator in m_generationEnumerators)
488 { 488 {
489 enumerator.Reset(); 489 enumerator.Reset();
490 } 490 }
@@ -582,7 +582,7 @@ namespace OpenSim.Framework
582 /// <param name="cache"> 582 /// <param name="cache">
583 /// The cache. 583 /// The cache.
584 /// </param> 584 /// </param>
585 public HashGeneration( CnmMemoryCache<TKey, TValue> cache ) 585 public HashGeneration(CnmMemoryCache<TKey, TValue> cache)
586 { 586 {
587 m_cache = cache; 587 m_cache = cache;
588 m_elements = new Element[m_cache.m_generationElementCount]; 588 m_elements = new Element[m_cache.m_generationElementCount];
@@ -608,16 +608,16 @@ namespace OpenSim.Framework
608 /// <returns> 608 /// <returns>
609 /// Element's index, if found from the generation; -1 otherwise (if element is not found the generation). 609 /// Element's index, if found from the generation; -1 otherwise (if element is not found the generation).
610 /// </returns> 610 /// </returns>
611 private int FindElementIndex( int bucketIndex, TKey key, bool moveToFront, out int previousIndex ) 611 private int FindElementIndex(int bucketIndex, TKey key, bool moveToFront, out int previousIndex)
612 { 612 {
613 previousIndex = -1; 613 previousIndex = -1;
614 int elementIndex = m_buckets[ bucketIndex ]; 614 int elementIndex = m_buckets[ bucketIndex ];
615 while( elementIndex >= 0 ) 615 while (elementIndex >= 0)
616 { 616 {
617 if( m_cache.Comparer.Equals( key, m_elements[ elementIndex ].Key ) ) 617 if (m_cache.Comparer.Equals(key, m_elements[ elementIndex ].Key))
618 { 618 {
619 // Found match 619 // Found match
620 if( moveToFront && previousIndex >= 0 ) 620 if (moveToFront && previousIndex >= 0)
621 { 621 {
622 // Move entry to front 622 // Move entry to front
623 m_elements[ previousIndex ].Next = m_elements[ elementIndex ].Next; 623 m_elements[ previousIndex ].Next = m_elements[ elementIndex ].Next;
@@ -648,9 +648,9 @@ namespace OpenSim.Framework
648 /// <param name="previousIndex"> 648 /// <param name="previousIndex">
649 /// The element's previous index. 649 /// The element's previous index.
650 /// </param> 650 /// </param>
651 private void RemoveElement( int bucketIndex, int entryIndex, int previousIndex ) 651 private void RemoveElement(int bucketIndex, int entryIndex, int previousIndex)
652 { 652 {
653 if( previousIndex >= 0 ) 653 if (previousIndex >= 0)
654 m_elements[ previousIndex ].Next = m_elements[ entryIndex ].Next; 654 m_elements[ previousIndex ].Next = m_elements[ entryIndex ].Next;
655 else 655 else
656 m_buckets[ bucketIndex ] = m_elements[ entryIndex ].Next; 656 m_buckets[ bucketIndex ] = m_elements[ entryIndex ].Next;
@@ -755,7 +755,7 @@ namespace OpenSim.Framework
755 /// <param name="generation"> 755 /// <param name="generation">
756 /// The generation. 756 /// The generation.
757 /// </param> 757 /// </param>
758 public Enumerator( HashGeneration generation ) 758 public Enumerator(HashGeneration generation)
759 { 759 {
760 m_generation = generation; 760 m_generation = generation;
761 m_version = m_generation.m_cache.m_version; 761 m_version = m_generation.m_cache.m_version;
@@ -776,7 +776,7 @@ namespace OpenSim.Framework
776 { 776 {
777 get 777 get
778 { 778 {
779 if( m_currentIndex == 0 || m_currentIndex >= m_generation.Count ) 779 if (m_currentIndex == 0 || m_currentIndex >= m_generation.Count)
780 throw new InvalidOperationException(); 780 throw new InvalidOperationException();
781 781
782 return m_current; 782 return m_current;
@@ -816,19 +816,19 @@ namespace OpenSim.Framework
816 /// </exception> 816 /// </exception>
817 public bool MoveNext() 817 public bool MoveNext()
818 { 818 {
819 if( m_version != m_generation.m_cache.m_version ) 819 if (m_version != m_generation.m_cache.m_version)
820 throw new InvalidOperationException(); 820 throw new InvalidOperationException();
821 821
822 while( m_currentIndex < m_generation.Count ) 822 while (m_currentIndex < m_generation.Count)
823 { 823 {
824 if( m_generation.m_elements[ m_currentIndex ].IsFree ) 824 if (m_generation.m_elements[ m_currentIndex ].IsFree)
825 { 825 {
826 m_currentIndex++; 826 m_currentIndex++;
827 continue; 827 continue;
828 } 828 }
829 829
830 m_current = new KeyValuePair<TKey, TValue>( m_generation.m_elements[ m_currentIndex ].Key, 830 m_current = new KeyValuePair<TKey, TValue>(m_generation.m_elements[ m_currentIndex ].Key,
831 m_generation.m_elements[ m_currentIndex ].Value ); 831 m_generation.m_elements[ m_currentIndex ].Value);
832 m_currentIndex++; 832 m_currentIndex++;
833 return true; 833 return true;
834 } 834 }
@@ -846,7 +846,7 @@ namespace OpenSim.Framework
846 /// <filterpriority>2</filterpriority> 846 /// <filterpriority>2</filterpriority>
847 public void Reset() 847 public void Reset()
848 { 848 {
849 if( m_version != m_generation.m_cache.m_version ) 849 if (m_version != m_generation.m_cache.m_version)
850 throw new InvalidOperationException(); 850 throw new InvalidOperationException();
851 851
852 m_currentIndex = 0; 852 m_currentIndex = 0;
@@ -907,12 +907,12 @@ namespace OpenSim.Framework
907 /// <seealso cref="IGeneration.MakeOld"/> 907 /// <seealso cref="IGeneration.MakeOld"/>
908 public void Clear() 908 public void Clear()
909 { 909 {
910 for( int i = m_buckets.Length - 1 ; i >= 0 ; i-- ) 910 for (int i = m_buckets.Length - 1 ; i >= 0 ; i--)
911 { 911 {
912 m_buckets[ i ] = -1; 912 m_buckets[ i ] = -1;
913 } 913 }
914 914
915 Array.Clear( m_elements, 0, m_elements.Length ); 915 Array.Clear(m_elements, 0, m_elements.Length);
916 Size = 0; 916 Size = 0;
917 m_firstFreeElement = -1; 917 m_firstFreeElement = -1;
918 m_freeCount = 0; 918 m_freeCount = 0;
@@ -934,10 +934,10 @@ namespace OpenSim.Framework
934 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>; 934 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>;
935 /// otherwise <see langword="false"/>. 935 /// otherwise <see langword="false"/>.
936 /// </returns> 936 /// </returns>
937 public bool Contains( int bucketIndex, TKey key ) 937 public bool Contains(int bucketIndex, TKey key)
938 { 938 {
939 int previousIndex; 939 int previousIndex;
940 if( FindElementIndex( bucketIndex, key, true, out previousIndex ) == -1 ) 940 if (FindElementIndex(bucketIndex, key, true, out previousIndex) == -1)
941 return false; 941 return false;
942 942
943 AccessedSinceLastTimeCheck = true; 943 AccessedSinceLastTimeCheck = true;
@@ -953,7 +953,7 @@ namespace OpenSim.Framework
953 /// <filterpriority>1</filterpriority> 953 /// <filterpriority>1</filterpriority>
954 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() 954 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
955 { 955 {
956 return new Enumerator( this ); 956 return new Enumerator(this);
957 } 957 }
958 958
959 /// <summary> 959 /// <summary>
@@ -980,13 +980,13 @@ namespace OpenSim.Framework
980 /// <returns> 980 /// <returns>
981 /// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>. 981 /// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>.
982 /// </returns> 982 /// </returns>
983 public bool Remove( int bucketIndex, TKey key ) 983 public bool Remove(int bucketIndex, TKey key)
984 { 984 {
985 int previousIndex; 985 int previousIndex;
986 int entryIndex = FindElementIndex( bucketIndex, key, false, out previousIndex ); 986 int entryIndex = FindElementIndex(bucketIndex, key, false, out previousIndex);
987 if( entryIndex != -1 ) 987 if (entryIndex != -1)
988 { 988 {
989 RemoveElement( bucketIndex, entryIndex, previousIndex ); 989 RemoveElement(bucketIndex, entryIndex, previousIndex);
990 AccessedSinceLastTimeCheck = true; 990 AccessedSinceLastTimeCheck = true;
991 return true; 991 return true;
992 } 992 }
@@ -1020,18 +1020,18 @@ namespace OpenSim.Framework
1020 /// size must fit generation's limits, before element is added to generation. 1020 /// size must fit generation's limits, before element is added to generation.
1021 /// </para> 1021 /// </para>
1022 /// </remarks> 1022 /// </remarks>
1023 public bool Set( int bucketIndex, TKey key, TValue value, long size ) 1023 public bool Set(int bucketIndex, TKey key, TValue value, long size)
1024 { 1024 {
1025 Debug.Assert( m_newGeneration, "It is possible to insert new elements only to newest generation." ); 1025 Debug.Assert(m_newGeneration, "It is possible to insert new elements only to newest generation.");
1026 Debug.Assert( size > 0, "New element size should be more than 0." ); 1026 Debug.Assert(size > 0, "New element size should be more than 0.");
1027 1027
1028 int previousIndex; 1028 int previousIndex;
1029 int elementIndex = FindElementIndex( bucketIndex, key, true, out previousIndex ); 1029 int elementIndex = FindElementIndex(bucketIndex, key, true, out previousIndex);
1030 if( elementIndex == -1 ) 1030 if (elementIndex == -1)
1031 { 1031 {
1032 // New key 1032 // New key
1033 if( Size + size > m_cache.m_generationMaxSize || 1033 if (Size + size > m_cache.m_generationMaxSize ||
1034 (m_nextUnusedElement == m_cache.m_generationElementCount && m_freeCount == 0) ) 1034 (m_nextUnusedElement == m_cache.m_generationElementCount && m_freeCount == 0))
1035 { 1035 {
1036 // Generation is full 1036 // Generation is full
1037 return false; 1037 return false;
@@ -1041,7 +1041,7 @@ namespace OpenSim.Framework
1041 Size += size; 1041 Size += size;
1042 1042
1043 // Get first free entry and update free entry list 1043 // Get first free entry and update free entry list
1044 if( m_firstFreeElement != -1 ) 1044 if (m_firstFreeElement != -1)
1045 { 1045 {
1046 // There was entry that was removed 1046 // There was entry that was removed
1047 elementIndex = m_firstFreeElement; 1047 elementIndex = m_firstFreeElement;
@@ -1055,7 +1055,7 @@ namespace OpenSim.Framework
1055 m_nextUnusedElement++; 1055 m_nextUnusedElement++;
1056 } 1056 }
1057 1057
1058 Debug.Assert( m_elements[ elementIndex ].IsFree, "Allocated element is not free." ); 1058 Debug.Assert(m_elements[ elementIndex ].IsFree, "Allocated element is not free.");
1059 1059
1060 // Move new entry to front 1060 // Move new entry to front
1061 m_elements[ elementIndex ].Next = m_buckets[ bucketIndex ]; 1061 m_elements[ elementIndex ].Next = m_buckets[ bucketIndex ];
@@ -1067,12 +1067,12 @@ namespace OpenSim.Framework
1067 else 1067 else
1068 { 1068 {
1069 // Existing key 1069 // Existing key
1070 if( Size - m_elements[ elementIndex ].Size + size > m_cache.m_generationMaxSize ) 1070 if (Size - m_elements[ elementIndex ].Size + size > m_cache.m_generationMaxSize)
1071 { 1071 {
1072 // Generation is full 1072 // Generation is full
1073 // Remove existing element, because generation is going to be recycled to 1073 // Remove existing element, because generation is going to be recycled to
1074 // old generation and element is stored to new generation 1074 // old generation and element is stored to new generation
1075 RemoveElement( bucketIndex, elementIndex, previousIndex ); 1075 RemoveElement(bucketIndex, elementIndex, previousIndex);
1076 return false; 1076 return false;
1077 } 1077 }
1078 1078
@@ -1113,12 +1113,12 @@ namespace OpenSim.Framework
1113 /// are set to default value (default(TValue) and 0). 1113 /// are set to default value (default(TValue) and 0).
1114 /// </para> 1114 /// </para>
1115 /// </remarks> 1115 /// </remarks>
1116 public bool TryGetValue( int bucketIndex, TKey key, out TValue value, out long size ) 1116 public bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size)
1117 { 1117 {
1118 // Find entry index, 1118 // Find entry index,
1119 int previousIndex; 1119 int previousIndex;
1120 int elementIndex = FindElementIndex( bucketIndex, key, m_newGeneration, out previousIndex ); 1120 int elementIndex = FindElementIndex(bucketIndex, key, m_newGeneration, out previousIndex);
1121 if( elementIndex == -1 ) 1121 if (elementIndex == -1)
1122 { 1122 {
1123 value = default(TValue); 1123 value = default(TValue);
1124 size = 0; 1124 size = 0;
@@ -1128,10 +1128,10 @@ namespace OpenSim.Framework
1128 value = m_elements[ elementIndex ].Value; 1128 value = m_elements[ elementIndex ].Value;
1129 size = m_elements[ elementIndex ].Size; 1129 size = m_elements[ elementIndex ].Size;
1130 1130
1131 if( !m_newGeneration ) 1131 if (!m_newGeneration)
1132 { 1132 {
1133 // Old generation - remove element, because it is moved to new generation 1133 // Old generation - remove element, because it is moved to new generation
1134 RemoveElement( bucketIndex, elementIndex, previousIndex ); 1134 RemoveElement(bucketIndex, elementIndex, previousIndex);
1135 } 1135 }
1136 1136
1137 AccessedSinceLastTimeCheck = true; 1137 AccessedSinceLastTimeCheck = true;
@@ -1214,7 +1214,7 @@ namespace OpenSim.Framework
1214 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>; 1214 /// <see langword="true"/>if the <see cref="IGeneration"/> contains an element with the <see cref="key"/>;
1215 /// otherwise <see langword="false"/>. 1215 /// otherwise <see langword="false"/>.
1216 /// </returns> 1216 /// </returns>
1217 bool Contains( int bucketIndex, TKey key ); 1217 bool Contains(int bucketIndex, TKey key);
1218 1218
1219 /// <summary> 1219 /// <summary>
1220 /// Make from generation old generation. 1220 /// Make from generation old generation.
@@ -1237,7 +1237,7 @@ namespace OpenSim.Framework
1237 /// <returns> 1237 /// <returns>
1238 /// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>. 1238 /// <see langword="true"/>, if remove was successful; otherwise <see langword="false"/>.
1239 /// </returns> 1239 /// </returns>
1240 bool Remove( int bucketIndex, TKey key ); 1240 bool Remove(int bucketIndex, TKey key);
1241 1241
1242 /// <summary> 1242 /// <summary>
1243 /// Set or add element to generation. 1243 /// Set or add element to generation.
@@ -1265,7 +1265,7 @@ namespace OpenSim.Framework
1265 /// size must fit generation's limits, before element is added to generation. 1265 /// size must fit generation's limits, before element is added to generation.
1266 /// </para> 1266 /// </para>
1267 /// </remarks> 1267 /// </remarks>
1268 bool Set( int bucketIndex, TKey key, TValue value, long size ); 1268 bool Set(int bucketIndex, TKey key, TValue value, long size);
1269 1269
1270 /// <summary> 1270 /// <summary>
1271 /// Try to get element associated with key. 1271 /// Try to get element associated with key.
@@ -1291,7 +1291,7 @@ namespace OpenSim.Framework
1291 /// are set to default value (default(TValue) and 0). 1291 /// are set to default value (default(TValue) and 0).
1292 /// </para> 1292 /// </para>
1293 /// </remarks> 1293 /// </remarks>
1294 bool TryGetValue( int bucketIndex, TKey key, out TValue value, out long size ); 1294 bool TryGetValue(int bucketIndex, TKey key, out TValue value, out long size);
1295 } 1295 }
1296 1296
1297 #endregion 1297 #endregion
@@ -1357,10 +1357,10 @@ namespace OpenSim.Framework
1357 1357
1358 set 1358 set
1359 { 1359 {
1360 if( value < MinExpirationTime ) 1360 if (value < MinExpirationTime)
1361 value = MinExpirationTime; 1361 value = MinExpirationTime;
1362 1362
1363 if( m_expirationTime == value ) 1363 if (m_expirationTime == value)
1364 return; 1364 return;
1365 1365
1366 m_newGeneration.ExpirationTime = (m_newGeneration.ExpirationTime - m_expirationTime) + value; 1366 m_newGeneration.ExpirationTime = (m_newGeneration.ExpirationTime - m_expirationTime) + value;
@@ -1478,9 +1478,9 @@ namespace OpenSim.Framework
1478 1478
1479 set 1479 set
1480 { 1480 {
1481 if( value < 8 ) 1481 if (value < 8)
1482 value = 8; 1482 value = 8;
1483 if( m_maxCount == value ) 1483 if (m_maxCount == value)
1484 return; 1484 return;
1485 1485
1486 m_maxCount = value; 1486 m_maxCount = value;
@@ -1535,9 +1535,9 @@ namespace OpenSim.Framework
1535 1535
1536 set 1536 set
1537 { 1537 {
1538 if( value < 8 ) 1538 if (value < 8)
1539 value = 8; 1539 value = 8;
1540 if( m_maxSize == value ) 1540 if (m_maxSize == value)
1541 return; 1541 return;
1542 1542
1543 m_maxSize = value; 1543 m_maxSize = value;
@@ -1618,7 +1618,7 @@ namespace OpenSim.Framework
1618 /// <filterpriority>1</filterpriority> 1618 /// <filterpriority>1</filterpriority>
1619 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() 1619 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
1620 { 1620 {
1621 return new Enumerator( this ); 1621 return new Enumerator(this);
1622 } 1622 }
1623 1623
1624 /// <summary> 1624 /// <summary>
@@ -1644,28 +1644,28 @@ namespace OpenSim.Framework
1644 { 1644 {
1645 m_operationsBetweenTimeChecks = DefaultOperationsBetweenTimeChecks; 1645 m_operationsBetweenTimeChecks = DefaultOperationsBetweenTimeChecks;
1646 1646
1647 if( !IsTimeLimited ) 1647 if (!IsTimeLimited)
1648 return; 1648 return;
1649 1649
1650 DateTime now = DateTime.Now; 1650 DateTime now = DateTime.Now;
1651 if( m_newGeneration.AccessedSinceLastTimeCheck ) 1651 if (m_newGeneration.AccessedSinceLastTimeCheck)
1652 { 1652 {
1653 // New generation has been accessed since last check 1653 // New generation has been accessed since last check
1654 // Update it's expiration time. 1654 // Update it's expiration time.
1655 m_newGeneration.ExpirationTime = now + ExpirationTime; 1655 m_newGeneration.ExpirationTime = now + ExpirationTime;
1656 m_newGeneration.AccessedSinceLastTimeCheck = false; 1656 m_newGeneration.AccessedSinceLastTimeCheck = false;
1657 } 1657 }
1658 else if( m_newGeneration.ExpirationTime < now ) 1658 else if (m_newGeneration.ExpirationTime < now)
1659 { 1659 {
1660 // New generation has been expired. 1660 // New generation has been expired.
1661 // --> also old generation must be expired. 1661 // --> also old generation must be expired.
1662 PurgeGeneration( m_newGeneration ); 1662 PurgeGeneration(m_newGeneration);
1663 PurgeGeneration( m_oldGeneration ); 1663 PurgeGeneration(m_oldGeneration);
1664 return; 1664 return;
1665 } 1665 }
1666 1666
1667 if( m_oldGeneration.ExpirationTime < now ) 1667 if (m_oldGeneration.ExpirationTime < now)
1668 PurgeGeneration( m_oldGeneration ); 1668 PurgeGeneration(m_oldGeneration);
1669 } 1669 }
1670 1670
1671 /// <summary> 1671 /// <summary>
@@ -1682,15 +1682,15 @@ namespace OpenSim.Framework
1682 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 1682 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
1683 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 1683 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
1684 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 1684 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
1685 public void Remove( TKey key ) 1685 public void Remove(TKey key)
1686 { 1686 {
1687 if( key == null ) 1687 if (key == null)
1688 throw new ArgumentNullException( "key" ); 1688 throw new ArgumentNullException("key");
1689 1689
1690 int bucketIndex = GetBucketIndex( key ); 1690 int bucketIndex = GetBucketIndex(key);
1691 if( !m_newGeneration.Remove( bucketIndex, key ) ) 1691 if (!m_newGeneration.Remove(bucketIndex, key))
1692 { 1692 {
1693 if( !m_oldGeneration.Remove( bucketIndex, key ) ) 1693 if (!m_oldGeneration.Remove(bucketIndex, key))
1694 { 1694 {
1695 CheckExpired(); 1695 CheckExpired();
1696 return; 1696 return;
@@ -1715,19 +1715,19 @@ namespace OpenSim.Framework
1715 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 1715 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
1716 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 1716 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
1717 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 1717 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
1718 public void RemoveRange( IEnumerable<TKey> keys ) 1718 public void RemoveRange(IEnumerable<TKey> keys)
1719 { 1719 {
1720 if( keys == null ) 1720 if (keys == null)
1721 throw new ArgumentNullException( "keys" ); 1721 throw new ArgumentNullException("keys");
1722 1722
1723 foreach( TKey key in keys ) 1723 foreach (TKey key in keys)
1724 { 1724 {
1725 if( key == null ) 1725 if (key == null)
1726 continue; 1726 continue;
1727 1727
1728 int bucketIndex = GetBucketIndex( key ); 1728 int bucketIndex = GetBucketIndex(key);
1729 if( !m_newGeneration.Remove( bucketIndex, key ) ) 1729 if (!m_newGeneration.Remove(bucketIndex, key))
1730 m_oldGeneration.Remove( bucketIndex, key ); 1730 m_oldGeneration.Remove(bucketIndex, key);
1731 } 1731 }
1732 1732
1733 CheckExpired(); 1733 CheckExpired();
@@ -1779,27 +1779,27 @@ namespace OpenSim.Framework
1779 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 1779 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
1780 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 1780 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
1781 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 1781 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
1782 public bool Set( TKey key, TValue value, long size ) 1782 public bool Set(TKey key, TValue value, long size)
1783 { 1783 {
1784 if( key == null ) 1784 if (key == null)
1785 throw new ArgumentNullException( "key" ); 1785 throw new ArgumentNullException("key");
1786 1786
1787 if( size < 0 ) 1787 if (size < 0)
1788 throw new ArgumentOutOfRangeException( "size", size, "Value's size can't be less than 0." ); 1788 throw new ArgumentOutOfRangeException("size", size, "Value's size can't be less than 0.");
1789 1789
1790 if( size > MaxElementSize ) 1790 if (size > MaxElementSize)
1791 { 1791 {
1792 // Entry size is too big to fit cache - ignore it 1792 // Entry size is too big to fit cache - ignore it
1793 Remove( key ); 1793 Remove(key);
1794 return false; 1794 return false;
1795 } 1795 }
1796 1796
1797 if( size == 0 ) 1797 if (size == 0)
1798 size = 1; 1798 size = 1;
1799 1799
1800 int bucketIndex = GetBucketIndex( key ); 1800 int bucketIndex = GetBucketIndex(key);
1801 m_oldGeneration.Remove( bucketIndex, key ); 1801 m_oldGeneration.Remove(bucketIndex, key);
1802 AddToNewGeneration( bucketIndex, key, value, size ); 1802 AddToNewGeneration(bucketIndex, key, value, size);
1803 CheckExpired(); 1803 CheckExpired();
1804 1804
1805 return true; 1805 return true;
@@ -1828,23 +1828,23 @@ namespace OpenSim.Framework
1828 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/> 1828 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
1829 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 1829 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
1830 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 1830 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
1831 public bool TryGetValue( TKey key, out TValue value ) 1831 public bool TryGetValue(TKey key, out TValue value)
1832 { 1832 {
1833 if( key == null ) 1833 if (key == null)
1834 throw new ArgumentNullException( "key" ); 1834 throw new ArgumentNullException("key");
1835 1835
1836 int bucketIndex = GetBucketIndex( key ); 1836 int bucketIndex = GetBucketIndex(key);
1837 long size; 1837 long size;
1838 if( m_newGeneration.TryGetValue( bucketIndex, key, out value, out size ) ) 1838 if (m_newGeneration.TryGetValue(bucketIndex, key, out value, out size))
1839 { 1839 {
1840 CheckExpired(); 1840 CheckExpired();
1841 return true; 1841 return true;
1842 } 1842 }
1843 1843
1844 if( m_oldGeneration.TryGetValue( bucketIndex, key, out value, out size ) ) 1844 if (m_oldGeneration.TryGetValue(bucketIndex, key, out value, out size))
1845 { 1845 {
1846 // Move element to new generation 1846 // Move element to new generation
1847 AddToNewGeneration( bucketIndex, key, value, size ); 1847 AddToNewGeneration(bucketIndex, key, value, size);
1848 CheckExpired(); 1848 CheckExpired();
1849 return true; 1849 return true;
1850 } 1850 }
diff --git a/OpenSim/Framework/CnmSynchronizedCache.cs b/OpenSim/Framework/CnmSynchronizedCache.cs
index bf588ce..c09900e 100644
--- a/OpenSim/Framework/CnmSynchronizedCache.cs
+++ b/OpenSim/Framework/CnmSynchronizedCache.cs
@@ -24,6 +24,7 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System; 28using System;
28using System.Collections; 29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
@@ -65,7 +66,7 @@ namespace OpenSim.Framework
65 /// <param name="cache"> 66 /// <param name="cache">
66 /// The cache. 67 /// The cache.
67 /// </param> 68 /// </param>
68 private CnmSynchronizedCache( ICnmCache<TKey, TValue> cache ) 69 private CnmSynchronizedCache(ICnmCache<TKey, TValue> cache)
69 { 70 {
70 m_cache = cache; 71 m_cache = cache;
71 m_syncRoot = m_cache.SyncRoot; 72 m_syncRoot = m_cache.SyncRoot;
@@ -83,11 +84,11 @@ namespace OpenSim.Framework
83 /// <exception cref="ArgumentNullException"> 84 /// <exception cref="ArgumentNullException">
84 /// <paramref name="cache"/>is null. 85 /// <paramref name="cache"/>is null.
85 /// </exception> 86 /// </exception>
86 public static ICnmCache<TKey, TValue> Synchronized( ICnmCache<TKey, TValue> cache ) 87 public static ICnmCache<TKey, TValue> Synchronized(ICnmCache<TKey, TValue> cache)
87 { 88 {
88 if( cache == null ) 89 if (cache == null)
89 throw new ArgumentNullException( "cache" ); 90 throw new ArgumentNullException("cache");
90 return cache.IsSynchronized ? cache : new CnmSynchronizedCache<TKey, TValue>( cache ); 91 return cache.IsSynchronized ? cache : new CnmSynchronizedCache<TKey, TValue>(cache);
91 } 92 }
92 93
93 #region Nested type: SynchronizedEnumerator 94 #region Nested type: SynchronizedEnumerator
@@ -116,11 +117,11 @@ namespace OpenSim.Framework
116 /// <param name="syncRoot"> 117 /// <param name="syncRoot">
117 /// The sync root. 118 /// The sync root.
118 /// </param> 119 /// </param>
119 public SynchronizedEnumerator( IEnumerator<KeyValuePair<TKey, TValue>> enumerator, object syncRoot ) 120 public SynchronizedEnumerator(IEnumerator<KeyValuePair<TKey, TValue>> enumerator, object syncRoot)
120 { 121 {
121 m_syncRoot = syncRoot; 122 m_syncRoot = syncRoot;
122 m_enumerator = enumerator; 123 m_enumerator = enumerator;
123 Monitor.Enter( m_syncRoot ); 124 Monitor.Enter(m_syncRoot);
124 } 125 }
125 126
126 /// <summary> 127 /// <summary>
@@ -166,14 +167,14 @@ namespace OpenSim.Framework
166 /// </summary> 167 /// </summary>
167 public void Dispose() 168 public void Dispose()
168 { 169 {
169 if( m_syncRoot != null ) 170 if (m_syncRoot != null)
170 { 171 {
171 Monitor.Exit( m_syncRoot ); 172 Monitor.Exit(m_syncRoot);
172 m_syncRoot = null; 173 m_syncRoot = null;
173 } 174 }
174 175
175 m_enumerator.Dispose(); 176 m_enumerator.Dispose();
176 GC.SuppressFinalize( this ); 177 GC.SuppressFinalize(this);
177 } 178 }
178 179
179 /// <summary> 180 /// <summary>
@@ -225,7 +226,7 @@ namespace OpenSim.Framework
225 { 226 {
226 get 227 get
227 { 228 {
228 lock( m_syncRoot ) 229 lock (m_syncRoot)
229 { 230 {
230 return m_cache.Count; 231 return m_cache.Count;
231 } 232 }
@@ -271,7 +272,7 @@ namespace OpenSim.Framework
271 { 272 {
272 get 273 get
273 { 274 {
274 lock( m_syncRoot ) 275 lock (m_syncRoot)
275 { 276 {
276 return m_cache.ExpirationTime; 277 return m_cache.ExpirationTime;
277 } 278 }
@@ -279,7 +280,7 @@ namespace OpenSim.Framework
279 280
280 set 281 set
281 { 282 {
282 lock( m_syncRoot ) 283 lock (m_syncRoot)
283 { 284 {
284 m_cache.ExpirationTime = value; 285 m_cache.ExpirationTime = value;
285 } 286 }
@@ -307,7 +308,7 @@ namespace OpenSim.Framework
307 { 308 {
308 get 309 get
309 { 310 {
310 lock( m_syncRoot ) 311 lock (m_syncRoot)
311 { 312 {
312 return m_cache.IsCountLimited; 313 return m_cache.IsCountLimited;
313 } 314 }
@@ -336,7 +337,7 @@ namespace OpenSim.Framework
336 { 337 {
337 get 338 get
338 { 339 {
339 lock( m_syncRoot ) 340 lock (m_syncRoot)
340 { 341 {
341 return m_cache.IsSizeLimited; 342 return m_cache.IsSizeLimited;
342 } 343 }
@@ -385,7 +386,7 @@ namespace OpenSim.Framework
385 { 386 {
386 get 387 get
387 { 388 {
388 lock( m_syncRoot ) 389 lock (m_syncRoot)
389 { 390 {
390 return m_cache.IsTimeLimited; 391 return m_cache.IsTimeLimited;
391 } 392 }
@@ -409,7 +410,7 @@ namespace OpenSim.Framework
409 { 410 {
410 get 411 get
411 { 412 {
412 lock( m_syncRoot ) 413 lock (m_syncRoot)
413 { 414 {
414 return m_cache.MaxCount; 415 return m_cache.MaxCount;
415 } 416 }
@@ -417,7 +418,7 @@ namespace OpenSim.Framework
417 418
418 set 419 set
419 { 420 {
420 lock( m_syncRoot ) 421 lock (m_syncRoot)
421 { 422 {
422 m_cache.MaxCount = value; 423 m_cache.MaxCount = value;
423 } 424 }
@@ -444,7 +445,7 @@ namespace OpenSim.Framework
444 { 445 {
445 get 446 get
446 { 447 {
447 lock( m_syncRoot ) 448 lock (m_syncRoot)
448 { 449 {
449 return m_cache.MaxElementSize; 450 return m_cache.MaxElementSize;
450 } 451 }
@@ -474,7 +475,7 @@ namespace OpenSim.Framework
474 { 475 {
475 get 476 get
476 { 477 {
477 lock( m_syncRoot ) 478 lock (m_syncRoot)
478 { 479 {
479 return m_cache.MaxSize; 480 return m_cache.MaxSize;
480 } 481 }
@@ -482,7 +483,7 @@ namespace OpenSim.Framework
482 483
483 set 484 set
484 { 485 {
485 lock( m_syncRoot ) 486 lock (m_syncRoot)
486 { 487 {
487 m_cache.MaxSize = value; 488 m_cache.MaxSize = value;
488 } 489 }
@@ -516,7 +517,7 @@ namespace OpenSim.Framework
516 { 517 {
517 get 518 get
518 { 519 {
519 lock( m_syncRoot ) 520 lock (m_syncRoot)
520 { 521 {
521 return m_cache.Size; 522 return m_cache.Size;
522 } 523 }
@@ -553,7 +554,7 @@ namespace OpenSim.Framework
553 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 554 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
554 public void Clear() 555 public void Clear()
555 { 556 {
556 lock( m_syncRoot ) 557 lock (m_syncRoot)
557 { 558 {
558 m_cache.Clear(); 559 m_cache.Clear();
559 } 560 }
@@ -568,9 +569,9 @@ namespace OpenSim.Framework
568 /// <filterpriority>1</filterpriority> 569 /// <filterpriority>1</filterpriority>
569 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() 570 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
570 { 571 {
571 lock( m_syncRoot ) 572 lock (m_syncRoot)
572 { 573 {
573 return new SynchronizedEnumerator( m_cache.GetEnumerator(), m_syncRoot ); 574 return new SynchronizedEnumerator(m_cache.GetEnumerator(), m_syncRoot);
574 } 575 }
575 } 576 }
576 577
@@ -595,7 +596,7 @@ namespace OpenSim.Framework
595 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 596 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
596 public void PurgeExpired() 597 public void PurgeExpired()
597 { 598 {
598 lock( m_syncRoot ) 599 lock (m_syncRoot)
599 { 600 {
600 m_cache.PurgeExpired(); 601 m_cache.PurgeExpired();
601 } 602 }
@@ -615,11 +616,11 @@ namespace OpenSim.Framework
615 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 616 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
616 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 617 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
617 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 618 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
618 public void Remove( TKey key ) 619 public void Remove(TKey key)
619 { 620 {
620 lock( m_syncRoot ) 621 lock (m_syncRoot)
621 { 622 {
622 m_cache.Remove( key ); 623 m_cache.Remove(key);
623 } 624 }
624 } 625 }
625 626
@@ -637,11 +638,11 @@ namespace OpenSim.Framework
637 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 638 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
638 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 639 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
639 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 640 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
640 public void RemoveRange( IEnumerable<TKey> keys ) 641 public void RemoveRange(IEnumerable<TKey> keys)
641 { 642 {
642 lock( m_syncRoot ) 643 lock (m_syncRoot)
643 { 644 {
644 m_cache.RemoveRange( keys ); 645 m_cache.RemoveRange(keys);
645 } 646 }
646 } 647 }
647 648
@@ -690,11 +691,11 @@ namespace OpenSim.Framework
690 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/> 691 /// <seealso cref="ICnmCache{TKey,TValue}.TryGetValue"/>
691 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 692 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
692 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 693 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
693 public bool Set( TKey key, TValue value, long size ) 694 public bool Set(TKey key, TValue value, long size)
694 { 695 {
695 lock( m_syncRoot ) 696 lock (m_syncRoot)
696 { 697 {
697 return m_cache.Set( key, value, size ); 698 return m_cache.Set(key, value, size);
698 } 699 }
699 } 700 }
700 701
@@ -721,11 +722,11 @@ namespace OpenSim.Framework
721 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/> 722 /// <seealso cref="ICnmCache{TKey,TValue}.RemoveRange"/>
722 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/> 723 /// <seealso cref="ICnmCache{TKey,TValue}.Clear"/>
723 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/> 724 /// <seealso cref="ICnmCache{TKey,TValue}.PurgeExpired"/>
724 public bool TryGetValue( TKey key, out TValue value ) 725 public bool TryGetValue(TKey key, out TValue value)
725 { 726 {
726 lock( m_syncRoot ) 727 lock (m_syncRoot)
727 { 728 {
728 return m_cache.TryGetValue( key, out value ); 729 return m_cache.TryGetValue(key, out value);
729 } 730 }
730 } 731 }
731 732
diff --git a/OpenSim/Framework/PrimeNumberHelper.cs b/OpenSim/Framework/PrimeNumberHelper.cs
index 589f87d..477c274 100644
--- a/OpenSim/Framework/PrimeNumberHelper.cs
+++ b/OpenSim/Framework/PrimeNumberHelper.cs
@@ -58,28 +58,28 @@ namespace OpenSim.Framework
58 /// <returns> 58 /// <returns>
59 /// Primer number that is equal or larger than <see cref="min"/>. If <see cref="min"/> is too large, return -1. 59 /// Primer number that is equal or larger than <see cref="min"/>. If <see cref="min"/> is too large, return -1.
60 /// </returns> 60 /// </returns>
61 public static int GetPrime( int min ) 61 public static int GetPrime(int min)
62 { 62 {
63 if( min <= 2 ) 63 if (min <= 2)
64 return 2; 64 return 2;
65 65
66 if( Primes[ Primes.Length - 1 ] < min ) 66 if (Primes[ Primes.Length - 1 ] < min)
67 { 67 {
68 for( int i = min | 1 ; i < 0x7FFFFFFF ; i += 2 ) 68 for (int i = min | 1 ; i < 0x7FFFFFFF ; i += 2)
69 { 69 {
70 if( IsPrime( i ) ) 70 if (IsPrime(i))
71 return i; 71 return i;
72 } 72 }
73 73
74 return -1; 74 return -1;
75 } 75 }
76 76
77 for( int i = Primes.Length - 2 ; i >= 0 ; i-- ) 77 for (int i = Primes.Length - 2 ; i >= 0 ; i--)
78 { 78 {
79 if( min == Primes[ i ] ) 79 if (min == Primes[ i ])
80 return min; 80 return min;
81 81
82 if( min > Primes[ i ] ) 82 if (min > Primes[ i ])
83 return Primes[ i + 1 ]; 83 return Primes[ i + 1 ];
84 } 84 }
85 85
@@ -95,17 +95,17 @@ namespace OpenSim.Framework
95 /// <returns> 95 /// <returns>
96 /// true, if <see cref="candinate"/> is prime number; otherwise false. 96 /// true, if <see cref="candinate"/> is prime number; otherwise false.
97 /// </returns> 97 /// </returns>
98 public static bool IsPrime( int candinate ) 98 public static bool IsPrime(int candinate)
99 { 99 {
100 if( (candinate & 1) == 0 ) 100 if ((candinate & 1) == 0)
101 101
102 // Even number - only prime if 2 102 // Even number - only prime if 2
103 return candinate == 2; 103 return candinate == 2;
104 104
105 int upperBound = (int) Math.Sqrt( candinate ); 105 int upperBound = (int) Math.Sqrt(candinate);
106 for( int i = 3 ; i < upperBound ; i += 2 ) 106 for (int i = 3 ; i < upperBound ; i += 2)
107 { 107 {
108 if( candinate % i == 0 ) 108 if (candinate % i == 0)
109 return false; 109 return false;
110 } 110 }
111 111
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
index 5e3d243..d42c9e2 100644
--- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
@@ -114,12 +114,12 @@ namespace OpenSim.Region.CoreModules.Asset
114 /// <summary> 114 /// <summary>
115 /// Asset's default expiration time in the cache. 115 /// Asset's default expiration time in the cache.
116 /// </summary> 116 /// </summary>
117 public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes( 30.0 ); 117 public static readonly TimeSpan DefaultExpirationTime = TimeSpan.FromMinutes(30.0);
118 118
119 /// <summary> 119 /// <summary>
120 /// Log manager instance. 120 /// Log manager instance.
121 /// </summary> 121 /// </summary>
122 private static readonly ILog Log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType ); 122 private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
123 123
124 /// <summary> 124 /// <summary>
125 /// Cache object. 125 /// Cache object.
@@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Asset
159 /// </summary> 159 /// </summary>
160 public void Initialize() 160 public void Initialize()
161 { 161 {
162 Initialize( DefaultMaxSize, DefaultMaxCount, DefaultExpirationTime ); 162 Initialize(DefaultMaxSize, DefaultMaxCount, DefaultExpirationTime);
163 } 163 }
164 164
165 /// <summary> 165 /// <summary>
@@ -174,16 +174,16 @@ namespace OpenSim.Region.CoreModules.Asset
174 /// <param name="expirationTime"> 174 /// <param name="expirationTime">
175 /// Asset's expiration time. 175 /// Asset's expiration time.
176 /// </param> 176 /// </param>
177 public void Initialize( long maximalSize, int maximalCount, TimeSpan expirationTime ) 177 public void Initialize(long maximalSize, int maximalCount, TimeSpan expirationTime)
178 { 178 {
179 if( maximalSize <= 0 || maximalCount <= 0 ) 179 if (maximalSize <= 0 || maximalCount <= 0)
180 { 180 {
181 Log.Info( "[ASSET CACHE]: Cenome asset cache is not enabled." ); 181 Log.Info("[ASSET CACHE]: Cenome asset cache is not enabled.");
182 m_enabled = false; 182 m_enabled = false;
183 return; 183 return;
184 } 184 }
185 185
186 if( expirationTime <= TimeSpan.Zero ) 186 if (expirationTime <= TimeSpan.Zero)
187 { 187 {
188 // Disable expiration time 188 // Disable expiration time
189 expirationTime = TimeSpan.MaxValue; 189 expirationTime = TimeSpan.MaxValue;
@@ -191,14 +191,14 @@ namespace OpenSim.Region.CoreModules.Asset
191 191
192 // Create cache and add synchronization wrapper over it 192 // Create cache and add synchronization wrapper over it
193 m_cache = 193 m_cache =
194 CnmSynchronizedCache<string, AssetBase>.Synchronized( new CnmMemoryCache<string, AssetBase>( 194 CnmSynchronizedCache<string, AssetBase>.Synchronized(new CnmMemoryCache<string, AssetBase>(
195 maximalSize, maximalCount, expirationTime ) ); 195 maximalSize, maximalCount, expirationTime));
196 m_enabled = true; 196 m_enabled = true;
197 Log.InfoFormat( 197 Log.InfoFormat(
198 "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = {0} bytes, MaxCount = {1}, ExpirationTime = {2})", 198 "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = {0} bytes, MaxCount = {1}, ExpirationTime = {2})",
199 maximalSize, 199 maximalSize,
200 maximalCount, 200 maximalCount,
201 expirationTime ); 201 expirationTime);
202 } 202 }
203 203
204 #region IImprovedAssetCache Members 204 #region IImprovedAssetCache Members
@@ -209,10 +209,10 @@ namespace OpenSim.Region.CoreModules.Asset
209 /// <param name="asset"> 209 /// <param name="asset">
210 /// The asset that is being cached. 210 /// The asset that is being cached.
211 /// </param> 211 /// </param>
212 public void Cache( AssetBase asset ) 212 public void Cache(AssetBase asset)
213 { 213 {
214 long size = asset.Data != null ? asset.Data.Length : 1; 214 long size = asset.Data != null ? asset.Data.Length : 1;
215 m_cache.Set( asset.ID, asset, size ); 215 m_cache.Set(asset.ID, asset, size);
216 m_cachedCount++; 216 m_cachedCount++;
217 } 217 }
218 218
@@ -230,9 +230,9 @@ namespace OpenSim.Region.CoreModules.Asset
230 /// <param name="id"> 230 /// <param name="id">
231 /// The expired asset's id. 231 /// The expired asset's id.
232 /// </param> 232 /// </param>
233 public void Expire( string id ) 233 public void Expire(string id)
234 { 234 {
235 m_cache.Remove( id ); 235 m_cache.Remove(id);
236 } 236 }
237 237
238 /// <summary> 238 /// <summary>
@@ -250,14 +250,14 @@ namespace OpenSim.Region.CoreModules.Asset
250 /// Cache doesn't guarantee in any situation that asset is stored to it. 250 /// Cache doesn't guarantee in any situation that asset is stored to it.
251 /// </para> 251 /// </para>
252 /// </remarks> 252 /// </remarks>
253 public AssetBase Get( string id ) 253 public AssetBase Get(string id)
254 { 254 {
255 m_getCount++; 255 m_getCount++;
256 AssetBase assetBase; 256 AssetBase assetBase;
257 if( m_cache.TryGetValue( id, out assetBase ) ) 257 if (m_cache.TryGetValue(id, out assetBase))
258 m_hitCount++; 258 m_hitCount++;
259 259
260 if( m_getCount == m_debugEpoch ) 260 if (m_getCount == m_debugEpoch)
261 { 261 {
262 Log.InfoFormat( 262 Log.InfoFormat(
263 "[ASSET CACHE]: Cached = {0}, Get = {1}, Hits = {2}%, Size = {3} bytes, Avg. A. Size = {4} bytes", 263 "[ASSET CACHE]: Cached = {0}, Get = {1}, Hits = {2}%, Size = {3} bytes, Avg. A. Size = {4} bytes",
@@ -265,7 +265,7 @@ namespace OpenSim.Region.CoreModules.Asset
265 m_getCount, 265 m_getCount,
266 ((double) m_hitCount / m_getCount) * 100.0, 266 ((double) m_hitCount / m_getCount) * 100.0,
267 m_cache.Size, 267 m_cache.Size,
268 m_cache.Size / m_cache.Count ); 268 m_cache.Size / m_cache.Count);
269 m_getCount = 0; 269 m_getCount = 0;
270 m_hitCount = 0; 270 m_hitCount = 0;
271 m_cachedCount = 0; 271 m_cachedCount = 0;
@@ -292,10 +292,10 @@ namespace OpenSim.Region.CoreModules.Asset
292 /// <param name="scene"> 292 /// <param name="scene">
293 /// Region's scene. 293 /// Region's scene.
294 /// </param> 294 /// </param>
295 public void AddRegion( Scene scene ) 295 public void AddRegion(Scene scene)
296 { 296 {
297 if( m_enabled ) 297 if (m_enabled)
298 scene.RegisterModuleInterface<IImprovedAssetCache>( this ); 298 scene.RegisterModuleInterface<IImprovedAssetCache>(this);
299 } 299 }
300 300
301 /// <summary> 301 /// <summary>
@@ -314,19 +314,19 @@ namespace OpenSim.Region.CoreModules.Asset
314 /// <param name="source"> 314 /// <param name="source">
315 /// Configuration source. 315 /// Configuration source.
316 /// </param> 316 /// </param>
317 public void Initialise( IConfigSource source ) 317 public void Initialise(IConfigSource source)
318 { 318 {
319 m_cache = null; 319 m_cache = null;
320 m_enabled = false; 320 m_enabled = false;
321 321
322 IConfig moduleConfig = source.Configs[ "Modules" ]; 322 IConfig moduleConfig = source.Configs[ "Modules" ];
323 if( moduleConfig == null ) 323 if (moduleConfig == null)
324 return; 324 return;
325 325
326 string name = moduleConfig.GetString( "AssetCaching" ); 326 string name = moduleConfig.GetString("AssetCaching");
327 Log.DebugFormat( "[XXX] name = {0} (this module's name: {1}", name, Name ); 327 Log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name);
328 328
329 if( name != Name ) 329 if (name != Name)
330 return; 330 return;
331 331
332 // This module is used 332 // This module is used
@@ -335,19 +335,19 @@ namespace OpenSim.Region.CoreModules.Asset
335 TimeSpan expirationTime = DefaultExpirationTime; 335 TimeSpan expirationTime = DefaultExpirationTime;
336 336
337 IConfig assetConfig = source.Configs[ "AssetCache" ]; 337 IConfig assetConfig = source.Configs[ "AssetCache" ];
338 if( assetConfig != null ) 338 if (assetConfig != null)
339 { 339 {
340 // Get optional configurations 340 // Get optional configurations
341 maxSize = assetConfig.GetLong( "MaxSize", DefaultMaxSize ); 341 maxSize = assetConfig.GetLong("MaxSize", DefaultMaxSize);
342 maxCount = assetConfig.GetInt( "MaxCount", DefaultMaxCount ); 342 maxCount = assetConfig.GetInt("MaxCount", DefaultMaxCount);
343 expirationTime = 343 expirationTime =
344 TimeSpan.FromMinutes( assetConfig.GetInt( "ExpirationTime", (int) DefaultExpirationTime.TotalMinutes ) ); 344 TimeSpan.FromMinutes(assetConfig.GetInt("ExpirationTime", (int) DefaultExpirationTime.TotalMinutes));
345 345
346 // Debugging purposes only 346 // Debugging purposes only
347 m_debugEpoch = assetConfig.GetInt( "DebugEpoch", 0 ); 347 m_debugEpoch = assetConfig.GetInt("DebugEpoch", 0);
348 } 348 }
349 349
350 Initialize( maxSize, maxCount, expirationTime ); 350 Initialize(maxSize, maxCount, expirationTime);
351 } 351 }
352 352
353 /// <summary> 353 /// <summary>
@@ -381,7 +381,7 @@ namespace OpenSim.Region.CoreModules.Asset
381 /// The extra function stub is just that much cleaner. 381 /// The extra function stub is just that much cleaner.
382 /// </para> 382 /// </para>
383 /// </remarks> 383 /// </remarks>
384 public void RegionLoaded( Scene scene ) 384 public void RegionLoaded(Scene scene)
385 { 385 {
386 } 386 }
387 387
@@ -391,7 +391,7 @@ namespace OpenSim.Region.CoreModules.Asset
391 /// <param name="scene"> 391 /// <param name="scene">
392 /// Region scene that is being removed. 392 /// Region scene that is being removed.
393 /// </param> 393 /// </param>
394 public void RemoveRegion( Scene scene ) 394 public void RemoveRegion(Scene scene)
395 { 395 {
396 } 396 }
397 397
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 9540bd4..b7c269d 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -230,7 +230,7 @@ namespace Flotsam.RegionModules.AssetCache
230 230
231 private void UpdateMemoryCache(string key, AssetBase asset) 231 private void UpdateMemoryCache(string key, AssetBase asset)
232 { 232 {
233 if( m_MemoryCacheEnabled ) 233 if (m_MemoryCacheEnabled)
234 { 234 {
235 if (m_MemoryExpiration > TimeSpan.Zero) 235 if (m_MemoryExpiration > TimeSpan.Zero)
236 { 236 {
@@ -404,7 +404,7 @@ namespace Flotsam.RegionModules.AssetCache
404 File.Delete(filename); 404 File.Delete(filename);
405 } 405 }
406 406
407 if( m_MemoryCacheEnabled ) 407 if (m_MemoryCacheEnabled)
408 m_MemoryCache.Remove(id); 408 m_MemoryCache.Remove(id);
409 } 409 }
410 catch (Exception e) 410 catch (Exception e)
@@ -423,7 +423,7 @@ namespace Flotsam.RegionModules.AssetCache
423 Directory.Delete(dir); 423 Directory.Delete(dir);
424 } 424 }
425 425
426 if( m_MemoryCacheEnabled ) 426 if (m_MemoryCacheEnabled)
427 m_MemoryCache.Clear(); 427 m_MemoryCache.Clear();
428 } 428 }
429 429
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index a547df5..8c3d993 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -332,7 +332,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
332 332
333 UUID oldID = UUID.Zero; 333 UUID oldID = UUID.Zero;
334 334
335 lock(part) 335 lock (part)
336 { 336 {
337 // mostly keep the values from before 337 // mostly keep the values from before
338 Primitive.TextureEntry tmptex = part.Shape.Textures; 338 Primitive.TextureEntry tmptex = part.Shape.Textures;
@@ -340,7 +340,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
340 // remove the old asset from the cache 340 // remove the old asset from the cache
341 oldID = tmptex.DefaultTexture.TextureID; 341 oldID = tmptex.DefaultTexture.TextureID;
342 342
343 if(Face == ALL_SIDES) 343 if (Face == ALL_SIDES)
344 { 344 {
345 tmptex.DefaultTexture.TextureID = asset.FullID; 345 tmptex.DefaultTexture.TextureID = asset.FullID;
346 } 346 }
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 036c4b8..d786df8 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
243 243
244 244
245 string grant = myConfig.GetString("GrantLSL",""); 245 string grant = myConfig.GetString("GrantLSL","");
246 if(grant.Length > 0) { 246 if (grant.Length > 0) {
247 foreach (string uuidl in grant.Split(',')) { 247 foreach (string uuidl in grant.Split(',')) {
248 string uuid = uuidl.Trim(" \t".ToCharArray()); 248 string uuid = uuidl.Trim(" \t".ToCharArray());
249 GrantLSL.Add(uuid, true); 249 GrantLSL.Add(uuid, true);
@@ -251,7 +251,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
251 } 251 }
252 252
253 grant = myConfig.GetString("GrantCS",""); 253 grant = myConfig.GetString("GrantCS","");
254 if(grant.Length > 0) { 254 if (grant.Length > 0) {
255 foreach (string uuidl in grant.Split(',')) { 255 foreach (string uuidl in grant.Split(',')) {
256 string uuid = uuidl.Trim(" \t".ToCharArray()); 256 string uuid = uuidl.Trim(" \t".ToCharArray());
257 GrantCS.Add(uuid, true); 257 GrantCS.Add(uuid, true);
@@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
259 } 259 }
260 260
261 grant = myConfig.GetString("GrantVB",""); 261 grant = myConfig.GetString("GrantVB","");
262 if(grant.Length > 0) { 262 if (grant.Length > 0) {
263 foreach (string uuidl in grant.Split(',')) { 263 foreach (string uuidl in grant.Split(',')) {
264 string uuid = uuidl.Trim(" \t".ToCharArray()); 264 string uuid = uuidl.Trim(" \t".ToCharArray());
265 GrantVB.Add(uuid, true); 265 GrantVB.Add(uuid, true);
@@ -267,7 +267,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
267 } 267 }
268 268
269 grant = myConfig.GetString("GrantJS",""); 269 grant = myConfig.GetString("GrantJS","");
270 if(grant.Length > 0) { 270 if (grant.Length > 0) {
271 foreach (string uuidl in grant.Split(',')) { 271 foreach (string uuidl in grant.Split(',')) {
272 string uuid = uuidl.Trim(" \t".ToCharArray()); 272 string uuid = uuidl.Trim(" \t".ToCharArray());
273 GrantJS.Add(uuid, true); 273 GrantJS.Add(uuid, true);
@@ -563,7 +563,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
563 } 563 }
564 564
565 // Group permissions 565 // Group permissions
566 if ( ( task.GroupID != UUID.Zero) && IsGroupMember(task.GroupID, user, 0) ) 566 if ((task.GroupID != UUID.Zero) && IsGroupMember(task.GroupID, user, 0))
567 return objectGroupMask; 567 return objectGroupMask;
568 568
569 return objectEveryoneMask; 569 return objectEveryoneMask;
@@ -650,7 +650,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
650 } 650 }
651 651
652 // Group members should be able to edit group objects 652 // Group members should be able to edit group objects
653 if ( (group.GroupID != UUID.Zero) && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) && IsGroupMember(group.GroupID, currentUser, 0) ) 653 if ((group.GroupID != UUID.Zero) && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) && IsGroupMember(group.GroupID, currentUser, 0))
654 { 654 {
655 // Return immediately, so that the administrator can shares group objects 655 // Return immediately, so that the administrator can shares group objects
656 return true; 656 return true;
@@ -731,7 +731,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
731 permission = true; 731 permission = true;
732 } 732 }
733 733
734 if( ( parcel.landData.GroupID != UUID.Zero) && IsGroupMember(parcel.landData.GroupID, user, groupPowers) ) 734 if ((parcel.landData.GroupID != UUID.Zero) && IsGroupMember(parcel.landData.GroupID, user, groupPowers))
735 { 735 {
736 permission = true; 736 permission = true;
737 } 737 }
@@ -758,7 +758,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
758 permission = true; 758 permission = true;
759 } 759 }
760 760
761 if( parcel.landData.IsGroupOwned && IsGroupMember(parcel.landData.GroupID, user, groupPowers) ) 761 if (parcel.landData.IsGroupOwned && IsGroupMember(parcel.landData.GroupID, user, groupPowers))
762 { 762 {
763 permission = true; 763 permission = true;
764 } 764 }
@@ -982,7 +982,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
982 if (part.GroupID == UUID.Zero) 982 if (part.GroupID == UUID.Zero)
983 return false; 983 return false;
984 984
985 if( !IsGroupMember(part.GroupID, user, 0) ) 985 if (!IsGroupMember(part.GroupID, user, 0))
986 return false; 986 return false;
987 987
988 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 988 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0)
@@ -1002,7 +1002,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1002 if (ti.GroupID == UUID.Zero) 1002 if (ti.GroupID == UUID.Zero)
1003 return false; 1003 return false;
1004 1004
1005 if( !IsGroupMember(ti.GroupID, user, 0) ) 1005 if (!IsGroupMember(ti.GroupID, user, 0))
1006 return false; 1006 return false;
1007 } 1007 }
1008 1008
@@ -1411,7 +1411,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1411 if (part.GroupID == UUID.Zero) 1411 if (part.GroupID == UUID.Zero)
1412 return false; 1412 return false;
1413 1413
1414 if( !IsGroupMember(part.GroupID, user, 0) ) 1414 if (!IsGroupMember(part.GroupID, user, 0))
1415 return false; 1415 return false;
1416 1416
1417 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 1417 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0)
@@ -1431,7 +1431,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1431 if (ti.GroupID == UUID.Zero) 1431 if (ti.GroupID == UUID.Zero)
1432 return false; 1432 return false;
1433 1433
1434 if( !IsGroupMember(ti.GroupID, user, 0) ) 1434 if (!IsGroupMember(ti.GroupID, user, 0))
1435 return false; 1435 return false;
1436 } 1436 }
1437 1437
@@ -1504,7 +1504,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1504 if (part.GroupID == UUID.Zero) 1504 if (part.GroupID == UUID.Zero)
1505 return false; 1505 return false;
1506 1506
1507 if( !IsGroupMember(part.GroupID, user, 0) ) 1507 if (!IsGroupMember(part.GroupID, user, 0))
1508 return false; 1508 return false;
1509 } 1509 }
1510 1510
@@ -1521,7 +1521,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1521 if (ti.GroupID == UUID.Zero) 1521 if (ti.GroupID == UUID.Zero)
1522 return false; 1522 return false;
1523 1523
1524 if( !IsGroupMember(ti.GroupID, user, 0) ) 1524 if (!IsGroupMember(ti.GroupID, user, 0))
1525 return false; 1525 return false;
1526 } 1526 }
1527 1527
@@ -1744,24 +1744,24 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1744 1744
1745 private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) { 1745 private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) {
1746 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); 1746 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType);
1747 switch(scriptType) { 1747 switch (scriptType) {
1748 case 0: 1748 case 0:
1749 if(GrantLSL.Count == 0 || GrantLSL.ContainsKey(ownerUUID.ToString())) { 1749 if (GrantLSL.Count == 0 || GrantLSL.ContainsKey(ownerUUID.ToString())) {
1750 return(true); 1750 return(true);
1751 } 1751 }
1752 break; 1752 break;
1753 case 1: 1753 case 1:
1754 if(GrantCS.Count == 0 || GrantCS.ContainsKey(ownerUUID.ToString())) { 1754 if (GrantCS.Count == 0 || GrantCS.ContainsKey(ownerUUID.ToString())) {
1755 return(true); 1755 return(true);
1756 } 1756 }
1757 break; 1757 break;
1758 case 2: 1758 case 2:
1759 if(GrantVB.Count == 0 || GrantVB.ContainsKey(ownerUUID.ToString())) { 1759 if (GrantVB.Count == 0 || GrantVB.ContainsKey(ownerUUID.ToString())) {
1760 return(true); 1760 return(true);
1761 } 1761 }
1762 break; 1762 break;
1763 case 3: 1763 case 3:
1764 if(GrantJS.Count == 0 || GrantJS.ContainsKey(ownerUUID.ToString())) { 1764 if (GrantJS.Count == 0 || GrantJS.ContainsKey(ownerUUID.ToString())) {
1765 return(true); 1765 return(true);
1766 } 1766 }
1767 break; 1767 break;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index a2a7392..8e3c688 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1526,14 +1526,14 @@ namespace OpenSim.Region.Framework.Scenes
1526 return; 1526 return;
1527 1527
1528 if (part.OwnerID != remoteClient.AgentId) 1528 if (part.OwnerID != remoteClient.AgentId)
1529 { 1529 {
1530 // Group permissions 1530 // Group permissions
1531 if ( (part.GroupID == UUID.Zero) || (remoteClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0) ) 1531 if ((part.GroupID == UUID.Zero) || (remoteClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0))
1532 return; 1532 return;
1533 } else { 1533 } else {
1534 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) 1534 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1535 return; 1535 return;
1536 } 1536 }
1537 1537
1538 if (!Permissions.CanCreateObjectInventory( 1538 if (!Permissions.CanCreateObjectInventory(
1539 itemBase.InvType, part.UUID, remoteClient.AgentId)) 1539 itemBase.InvType, part.UUID, remoteClient.AgentId))
@@ -1602,18 +1602,18 @@ namespace OpenSim.Region.Framework.Scenes
1602 destId); 1602 destId);
1603 return; 1603 return;
1604 } 1604 }
1605 1605
1606 // Must own the object, and have modify rights 1606 // Must own the object, and have modify rights
1607 if (srcPart.OwnerID != destPart.OwnerID) 1607 if (srcPart.OwnerID != destPart.OwnerID)
1608 { 1608 {
1609 // Group permissions 1609 // Group permissions
1610 if ( (destPart.GroupID == UUID.Zero) || (destPart.GroupID != srcPart.GroupID) || 1610 if ((destPart.GroupID == UUID.Zero) || (destPart.GroupID != srcPart.GroupID) ||
1611 ((destPart.GroupMask & (uint)PermissionMask.Modify) == 0) ) 1611 ((destPart.GroupMask & (uint)PermissionMask.Modify) == 0))
1612 return; 1612 return;
1613 } else { 1613 } else {
1614 if ((destPart.OwnerMask & (uint)PermissionMask.Modify) == 0) 1614 if ((destPart.OwnerMask & (uint)PermissionMask.Modify) == 0)
1615 return; 1615 return;
1616 } 1616 }
1617 1617
1618 if (destPart.ScriptAccessPin != pin) 1618 if (destPart.ScriptAccessPin != pin)
1619 { 1619 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 9cfc84f..d18af46 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -136,7 +136,7 @@ namespace OpenSim.Region.Framework.Scenes
136 { 136 {
137 m_AssetService = RequestModuleInterface<IAssetService>(); 137 m_AssetService = RequestModuleInterface<IAssetService>();
138 138
139 if( m_AssetService == null ) 139 if (m_AssetService == null)
140 { 140 {
141 throw new Exception("No IAssetService available."); 141 throw new Exception("No IAssetService available.");
142 } 142 }
@@ -1097,7 +1097,7 @@ namespace OpenSim.Region.Framework.Scenes
1097 1097
1098 IMessageTransferModule tr = RequestModuleInterface<IMessageTransferModule>(); 1098 IMessageTransferModule tr = RequestModuleInterface<IMessageTransferModule>();
1099 if (tr != null) 1099 if (tr != null)
1100 tr.SendInstantMessage(msg, delegate(bool success) {} ); 1100 tr.SendInstantMessage(msg, delegate(bool success) {});
1101 } 1101 }
1102 m_returns.Clear(); 1102 m_returns.Clear();
1103 } 1103 }
@@ -1465,7 +1465,7 @@ namespace OpenSim.Region.Framework.Scenes
1465 1465
1466 foreach (SceneObjectPart part in group.Children.Values) 1466 foreach (SceneObjectPart part in group.Children.Values)
1467 { 1467 {
1468 if (part.IsJoint() && ((part.ObjectFlags&(uint)PrimFlags.Physics) != 0) ) 1468 if (part.IsJoint() && ((part.ObjectFlags&(uint)PrimFlags.Physics) != 0))
1469 { 1469 {
1470 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? 1470 PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
1471 } 1471 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 911da5b..5c7ce43 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -342,13 +342,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
342 throw new Exception(errtext); 342 throw new Exception(errtext);
343 } 343 }
344 344
345 if(m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)l) == false) { 345 if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)l) == false) {
346 // Not allowed to compile to this language! 346 // Not allowed to compile to this language!
347 string errtext = String.Empty; 347 string errtext = String.Empty;
348 errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!"; 348 errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!";
349 throw new Exception(errtext); 349 throw new Exception(errtext);
350 } 350 }
351 351
352 string compileScript = Script; 352 string compileScript = Script;
353 353
354 if (l == enumCompileType.lsl) 354 if (l == enumCompileType.lsl)
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
index 5dfbdbc..3ca7f7c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
@@ -135,8 +135,8 @@ state another_state
135 [Test] 135 [Test]
136 public void TestLoneIdent() 136 public void TestLoneIdent()
137 { 137 {
138 // A lone ident should be removed completely as it's an error in C# 138 // A lone ident should be removed completely as it's an error in C#
139 // (MONO at least). 139 // (MONO at least).
140 string input = @"default 140 string input = @"default
141{ 141{
142 touch_start(integer num_detected) 142 touch_start(integer num_detected)
@@ -150,7 +150,7 @@ state another_state
150 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + 150 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
151 "\n {" + 151 "\n {" +
152 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" + 152 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" +
153 "\n ;" + 153 "\n ;" +
154 "\n }\n"; 154 "\n }\n";
155 155
156 CSCodeGenerator cg = new CSCodeGenerator(); 156 CSCodeGenerator cg = new CSCodeGenerator();