diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/VersionInfo.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/TaskInventoryDictionary.cs | 117 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 26 |
3 files changed, 126 insertions, 19 deletions
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index ec94b2d..0d4215b 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs | |||
@@ -29,7 +29,7 @@ namespace OpenSim | |||
29 | { | 29 | { |
30 | public class VersionInfo | 30 | public class VersionInfo |
31 | { | 31 | { |
32 | private const string VERSION_NUMBER = "0.6.9"; | 32 | private const string VERSION_NUMBER = "0.6.9-CM"; |
33 | private const Flavour VERSION_FLAVOUR = Flavour.Dev; | 33 | private const Flavour VERSION_FLAVOUR = Flavour.Dev; |
34 | 34 | ||
35 | public enum Flavour | 35 | public enum Flavour |
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs index 25ae6b0..4b9a509 100644 --- a/OpenSim/Framework/TaskInventoryDictionary.cs +++ b/OpenSim/Framework/TaskInventoryDictionary.cs | |||
@@ -27,9 +27,12 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
30 | using System.Xml; | 32 | using System.Xml; |
31 | using System.Xml.Schema; | 33 | using System.Xml.Schema; |
32 | using System.Xml.Serialization; | 34 | using System.Xml.Serialization; |
35 | using log4net; | ||
33 | using OpenMetaverse; | 36 | using OpenMetaverse; |
34 | 37 | ||
35 | namespace OpenSim.Framework | 38 | namespace OpenSim.Framework |
@@ -45,6 +48,111 @@ namespace OpenSim.Framework | |||
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 49 | ||
47 | private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem)); | 50 | private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem)); |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private Thread LockedByThread; | ||
54 | /// <value> | ||
55 | /// An advanced lock for inventory data | ||
56 | /// </value> | ||
57 | private System.Threading.ReaderWriterLockSlim m_itemLock = new System.Threading.ReaderWriterLockSlim(); | ||
58 | |||
59 | /// <summary> | ||
60 | /// Are we readlocked by the calling thread? | ||
61 | /// </summary> | ||
62 | public bool IsReadLockedByMe() | ||
63 | { | ||
64 | if (m_itemLock.RecursiveReadCount > 0) | ||
65 | { | ||
66 | return true; | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | return false; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Lock our inventory list for reading (many can read, one can write) | ||
76 | /// </summary> | ||
77 | public void LockItemsForRead(bool locked) | ||
78 | { | ||
79 | if (locked) | ||
80 | { | ||
81 | if (m_itemLock.IsWriteLockHeld && LockedByThread != null) | ||
82 | { | ||
83 | if (!LockedByThread.IsAlive) | ||
84 | { | ||
85 | //Locked by dead thread, reset. | ||
86 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | if (m_itemLock.RecursiveReadCount > 0) | ||
91 | { | ||
92 | m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
93 | m_itemLock.ExitReadLock(); | ||
94 | } | ||
95 | if (m_itemLock.RecursiveWriteCount > 0) | ||
96 | { | ||
97 | m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
98 | m_itemLock.ExitWriteLock(); | ||
99 | } | ||
100 | |||
101 | while (!m_itemLock.TryEnterReadLock(60000)) | ||
102 | { | ||
103 | m_log.Error("Thread lock detected while trying to aquire READ lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
104 | if (m_itemLock.IsWriteLockHeld) | ||
105 | { | ||
106 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | else | ||
111 | { | ||
112 | if (m_itemLock.RecursiveReadCount>0) | ||
113 | { | ||
114 | m_itemLock.ExitReadLock(); | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | /// <summary> | ||
120 | /// Lock our inventory list for writing (many can read, one can write) | ||
121 | /// </summary> | ||
122 | public void LockItemsForWrite(bool locked) | ||
123 | { | ||
124 | if (locked) | ||
125 | { | ||
126 | //Enter a write lock, wait indefinately for one to open. | ||
127 | if (m_itemLock.RecursiveReadCount > 0) | ||
128 | { | ||
129 | m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
130 | m_itemLock.ExitReadLock(); | ||
131 | } | ||
132 | if (m_itemLock.RecursiveWriteCount > 0) | ||
133 | { | ||
134 | m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
135 | m_itemLock.ExitWriteLock(); | ||
136 | } | ||
137 | while (!m_itemLock.TryEnterWriteLock(60000)) | ||
138 | { | ||
139 | m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
140 | if (m_itemLock.IsWriteLockHeld) | ||
141 | { | ||
142 | m_itemLock = new System.Threading.ReaderWriterLockSlim(); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | LockedByThread = Thread.CurrentThread; | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | if (m_itemLock.RecursiveWriteCount > 0) | ||
151 | { | ||
152 | m_itemLock.ExitWriteLock(); | ||
153 | } | ||
154 | } | ||
155 | } | ||
48 | 156 | ||
49 | #region ICloneable Members | 157 | #region ICloneable Members |
50 | 158 | ||
@@ -52,13 +160,12 @@ namespace OpenSim.Framework | |||
52 | { | 160 | { |
53 | TaskInventoryDictionary clone = new TaskInventoryDictionary(); | 161 | TaskInventoryDictionary clone = new TaskInventoryDictionary(); |
54 | 162 | ||
55 | lock (this) | 163 | m_itemLock.EnterReadLock(); |
164 | foreach (UUID uuid in Keys) | ||
56 | { | 165 | { |
57 | foreach (UUID uuid in Keys) | 166 | clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone()); |
58 | { | ||
59 | clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone()); | ||
60 | } | ||
61 | } | 167 | } |
168 | m_itemLock.ExitReadLock(); | ||
62 | 169 | ||
63 | return clone; | 170 | return clone; |
64 | } | 171 | } |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 1112497..b5e2872 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -990,19 +990,19 @@ namespace OpenSim.Framework | |||
990 | { | 990 | { |
991 | string os = String.Empty; | 991 | string os = String.Empty; |
992 | 992 | ||
993 | if (Environment.OSVersion.Platform != PlatformID.Unix) | 993 | // if (Environment.OSVersion.Platform != PlatformID.Unix) |
994 | { | 994 | // { |
995 | os = Environment.OSVersion.ToString(); | 995 | // os = Environment.OSVersion.ToString(); |
996 | } | 996 | // } |
997 | else | 997 | // else |
998 | { | 998 | // { |
999 | os = ReadEtcIssue(); | 999 | // os = ReadEtcIssue(); |
1000 | } | 1000 | // } |
1001 | 1001 | // | |
1002 | if (os.Length > 45) | 1002 | // if (os.Length > 45) |
1003 | { | 1003 | // { |
1004 | os = os.Substring(0, 45); | 1004 | // os = os.Substring(0, 45); |
1005 | } | 1005 | // } |
1006 | 1006 | ||
1007 | return os; | 1007 | return os; |
1008 | } | 1008 | } |