aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-03-18 23:05:49 +0000
committerJustin Clark-Casey (justincc)2014-03-18 23:05:49 +0000
commit7df325c275c90d5be750082a9b8dafd92ef14669 (patch)
treee5358c1ccb55cbf9ac0fa8ccd35146b458d0bcb4 /OpenSim
parentSet executable bit on Npgsql.dll for cygwin (diff)
downloadopensim-SC_OLD-7df325c275c90d5be750082a9b8dafd92ef14669.zip
opensim-SC_OLD-7df325c275c90d5be750082a9b8dafd92ef14669.tar.gz
opensim-SC_OLD-7df325c275c90d5be750082a9b8dafd92ef14669.tar.bz2
opensim-SC_OLD-7df325c275c90d5be750082a9b8dafd92ef14669.tar.xz
Extend locking in BlockingQueue to cover operations that are not guaranteed to be thread-safe
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/BlockingQueue.cs18
1 files changed, 8 insertions, 10 deletions
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs
index 3e90fac..d11ad11 100644
--- a/OpenSim/Framework/BlockingQueue.cs
+++ b/OpenSim/Framework/BlockingQueue.cs
@@ -98,11 +98,11 @@ namespace OpenSim.Framework
98 /// </remarks> 98 /// </remarks>
99 public bool Contains(T item) 99 public bool Contains(T item)
100 { 100 {
101 if (m_queue.Count < 1 && m_pqueue.Count < 1)
102 return false;
103
104 lock (m_queueSync) 101 lock (m_queueSync)
105 { 102 {
103 if (m_queue.Count < 1 && m_pqueue.Count < 1)
104 return false;
105
106 if (m_pqueue.Contains(item)) 106 if (m_pqueue.Contains(item))
107 return true; 107 return true;
108 return m_queue.Contains(item); 108 return m_queue.Contains(item);
@@ -112,12 +112,10 @@ namespace OpenSim.Framework
112 /// <summary> 112 /// <summary>
113 /// Return a count of the number of requests on this queue. 113 /// Return a count of the number of requests on this queue.
114 /// </summary> 114 /// </summary>
115 /// <remarks>
116 /// This method is not thread-safe. Do not rely on the result without consistent external locking.
117 /// </remarks>
118 public int Count() 115 public int Count()
119 { 116 {
120 return m_queue.Count + m_pqueue.Count; 117 lock (m_queueSync)
118 return m_queue.Count + m_pqueue.Count;
121 } 119 }
122 120
123 /// <summary> 121 /// <summary>
@@ -128,11 +126,11 @@ namespace OpenSim.Framework
128 /// </remarks> 126 /// </remarks>
129 public T[] GetQueueArray() 127 public T[] GetQueueArray()
130 { 128 {
131 if (m_queue.Count < 1 && m_pqueue.Count < 1)
132 return new T[0];
133
134 lock (m_queueSync) 129 lock (m_queueSync)
135 { 130 {
131 if (m_queue.Count < 1 && m_pqueue.Count < 1)
132 return new T[0];
133
136 return m_queue.ToArray(); 134 return m_queue.ToArray();
137 } 135 }
138 } 136 }