aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneViewer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneViewer.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs87
1 files changed, 56 insertions, 31 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index 501487a..8a0d288 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -38,27 +38,42 @@ namespace OpenSim.Region.Framework.Scenes
38{ 38{
39 public class SceneViewer : ISceneViewer 39 public class SceneViewer : ISceneViewer
40 { 40 {
41 /// <summary>
42 /// Is this scene viewer enabled?
43 /// </summary>
44 private bool IsEnabled { get; set; }
45
46 /// <summary>
47 /// The scene presence serviced by this viewer.
48 /// </summary>
41 protected ScenePresence m_presence; 49 protected ScenePresence m_presence;
50
51 /// <summary>
52 /// The queue of parts for which we need to send out updates.
53 /// </summary>
42 protected UpdateQueue m_partsUpdateQueue = new UpdateQueue(); 54 protected UpdateQueue m_partsUpdateQueue = new UpdateQueue();
55
56 /// <summary>
57 /// The queue of objects for which we need to send out updates.
58 /// </summary>
43 protected Queue<SceneObjectGroup> m_pendingObjects; 59 protected Queue<SceneObjectGroup> m_pendingObjects;
44 60
61 /// <summary>
62 /// The last update assocated with a given part update.
63 /// </summary>
45 protected Dictionary<UUID, ScenePartUpdate> m_updateTimes = new Dictionary<UUID, ScenePartUpdate>(); 64 protected Dictionary<UUID, ScenePartUpdate> m_updateTimes = new Dictionary<UUID, ScenePartUpdate>();
46 65
47 public SceneViewer()
48 {
49 }
50
51 public SceneViewer(ScenePresence presence) 66 public SceneViewer(ScenePresence presence)
52 { 67 {
53 m_presence = presence; 68 m_presence = presence;
69 IsEnabled = true;
54 } 70 }
55 71
56 /// <summary>
57 /// Add the part to the queue of parts for which we need to send an update to the client
58 /// </summary>
59 /// <param name="part"></param>
60 public void QueuePartForUpdate(SceneObjectPart part) 72 public void QueuePartForUpdate(SceneObjectPart part)
61 { 73 {
74 if (!IsEnabled)
75 return;
76
62 lock (m_partsUpdateQueue) 77 lock (m_partsUpdateQueue)
63 { 78 {
64 m_partsUpdateQueue.Enqueue(part); 79 m_partsUpdateQueue.Enqueue(part);
@@ -87,6 +102,11 @@ namespace OpenSim.Region.Framework.Scenes
87 102
88 lock (m_pendingObjects) 103 lock (m_pendingObjects)
89 { 104 {
105 // We must do this under lock so that we don't suffer a race condition if another thread closes the
106 // viewer
107 if (!IsEnabled)
108 return;
109
90 while (m_pendingObjects != null && m_pendingObjects.Count > 0) 110 while (m_pendingObjects != null && m_pendingObjects.Count > 0)
91 { 111 {
92 SceneObjectGroup g = m_pendingObjects.Dequeue(); 112 SceneObjectGroup g = m_pendingObjects.Dequeue();
@@ -119,7 +139,6 @@ namespace OpenSim.Region.Framework.Scenes
119 139
120 // We deal with the possibility that two updates occur at 140 // We deal with the possibility that two updates occur at
121 // the same unix time at the update point itself. 141 // the same unix time at the update point itself.
122
123 if ((update.LastFullUpdateTime < part.TimeStampFull) || part.ParentGroup.IsAttachment) 142 if ((update.LastFullUpdateTime < part.TimeStampFull) || part.ParentGroup.IsAttachment)
124 { 143 {
125 // m_log.DebugFormat( 144 // m_log.DebugFormat(
@@ -135,9 +154,7 @@ namespace OpenSim.Region.Framework.Scenes
135 // this update. If this happened, then subsequent 154 // this update. If this happened, then subsequent
136 // updates which occurred on the same tick or the 155 // updates which occurred on the same tick or the
137 // next tick of the last update would be ignored. 156 // next tick of the last update would be ignored.
138
139 update.LastFullUpdateTime = part.TimeStampFull; 157 update.LastFullUpdateTime = part.TimeStampFull;
140
141 } 158 }
142 else if (update.LastTerseUpdateTime <= part.TimeStampTerse) 159 else if (update.LastTerseUpdateTime <= part.TimeStampTerse)
143 { 160 {
@@ -176,38 +193,46 @@ namespace OpenSim.Region.Framework.Scenes
176 } 193 }
177 } 194 }
178 195
179 public void Reset() 196// public void Reset()
180 { 197// {
181 if (m_pendingObjects == null) 198// if (m_pendingObjects == null)
182 return; 199// return;
200//
201// lock (m_pendingObjects)
202// {
203// if (m_pendingObjects != null)
204// {
205// m_pendingObjects.Clear();
206// m_pendingObjects = null;
207// }
208// }
209// }
183 210
211 public void Close()
212 {
184 lock (m_pendingObjects) 213 lock (m_pendingObjects)
185 { 214 {
186 if (m_pendingObjects != null) 215 // We perform this under the m_pendingObjects lock in order to avoid a race condition with another
216 // thread on SendPrimUpdates()
217 IsEnabled = false;
218
219 lock (m_updateTimes)
187 { 220 {
188 m_pendingObjects.Clear(); 221 m_updateTimes.Clear();
189 m_pendingObjects = null;
190 } 222 }
191 }
192 }
193 223
194 public void Close() 224 lock (m_partsUpdateQueue)
195 { 225 {
196 lock (m_updateTimes) 226 m_partsUpdateQueue.Clear();
197 { 227 }
198 m_updateTimes.Clear();
199 }
200 lock (m_partsUpdateQueue)
201 {
202 m_partsUpdateQueue.Clear();
203 } 228 }
204 Reset();
205 } 229 }
206 230
207 public int GetPendingObjectsCount() 231 public int GetPendingObjectsCount()
208 { 232 {
209 if (m_pendingObjects != null) 233 if (m_pendingObjects != null)
210 return m_pendingObjects.Count; 234 lock (m_pendingObjects)
235 return m_pendingObjects.Count;
211 236
212 return 0; 237 return 0;
213 } 238 }