aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs93
1 files changed, 49 insertions, 44 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
index 5b125ea..cc65981 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
@@ -53,6 +53,14 @@ namespace OpenSim.Region.ClientStack.Linden
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GetTextureModule")] 53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GetTextureModule")]
54 public class GetTextureModule : INonSharedRegionModule 54 public class GetTextureModule : INonSharedRegionModule
55 { 55 {
56
57 struct aPollRequest
58 {
59 public PollServiceTextureEventArgs thepoll;
60 public UUID reqID;
61 public Hashtable request;
62 }
63
56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 64 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
57 65
58 private Scene m_scene; 66 private Scene m_scene;
@@ -64,8 +72,8 @@ namespace OpenSim.Region.ClientStack.Linden
64 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); 72 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
65 private static Thread[] m_workerThreads = null; 73 private static Thread[] m_workerThreads = null;
66 74
67 private static OpenMetaverse.BlockingQueue<PollServiceTextureEventArgs> m_queue = 75 private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue =
68 new OpenMetaverse.BlockingQueue<PollServiceTextureEventArgs>(); 76 new OpenMetaverse.BlockingQueue<aPollRequest>();
69 77
70 #region ISharedRegionModule Members 78 #region ISharedRegionModule Members
71 79
@@ -104,7 +112,7 @@ namespace OpenSim.Region.ClientStack.Linden
104 String.Format("TextureWorkerThread{0}", i), 112 String.Format("TextureWorkerThread{0}", i),
105 ThreadPriority.Normal, 113 ThreadPriority.Normal,
106 false, 114 false,
107 true, 115 false,
108 null, 116 null,
109 int.MaxValue); 117 int.MaxValue);
110 } 118 }
@@ -129,7 +137,8 @@ namespace OpenSim.Region.ClientStack.Linden
129 ~GetTextureModule() 137 ~GetTextureModule()
130 { 138 {
131 foreach (Thread t in m_workerThreads) 139 foreach (Thread t in m_workerThreads)
132 t.Abort(); 140 Watchdog.AbortThread(t.ManagedThreadId);
141
133 } 142 }
134 143
135 private class PollServiceTextureEventArgs : PollServiceEventArgs 144 private class PollServiceTextureEventArgs : PollServiceEventArgs
@@ -142,40 +151,50 @@ namespace OpenSim.Region.ClientStack.Linden
142 private Scene m_scene; 151 private Scene m_scene;
143 152
144 public PollServiceTextureEventArgs(UUID pId, Scene scene) : 153 public PollServiceTextureEventArgs(UUID pId, Scene scene) :
145 base(null, null, null, null, pId, 30000) 154 base(null, null, null, null, pId, int.MaxValue)
146 { 155 {
147 m_scene = scene; 156 m_scene = scene;
148 157
149 HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; 158 HasEvents = (x, y) =>
150 GetEvents = (x, y, s) =>
151 { 159 {
152 try 160 lock (responses)
153 { 161 return responses.ContainsKey(x);
154 return this.responses[x]; 162 };
155 } 163 GetEvents = (x, y) =>
156 finally 164 {
165 lock (responses)
157 { 166 {
158 responses.Remove(x); 167 try
168 {
169 return responses[x];
170 }
171 finally
172 {
173 responses.Remove(x);
174 }
159 } 175 }
160 }; 176 };
161 177
162 Request = (x, y) => 178 Request = (x, y) =>
163 { 179 {
164 y["RequestID"] = x.ToString(); 180 aPollRequest reqinfo = new aPollRequest();
165 lock (this.requests) 181 reqinfo.thepoll = this;
166 this.requests.Add(y); 182 reqinfo.reqID = x;
183 reqinfo.request = y;
167 184
168 m_queue.Enqueue(this); 185 m_queue.Enqueue(reqinfo);
169 }; 186 };
170 187
188 // this should never happen except possible on shutdown
171 NoEvents = (x, y) => 189 NoEvents = (x, y) =>
172 { 190 {
173 lock (this.requests) 191/*
192 lock (requests)
174 { 193 {
175 Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); 194 Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString());
176 requests.Remove(request); 195 requests.Remove(request);
177 } 196 }
178 197*/
179 Hashtable response = new Hashtable(); 198 Hashtable response = new Hashtable();
180 199
181 response["int_response_code"] = 500; 200 response["int_response_code"] = 500;
@@ -188,25 +207,11 @@ namespace OpenSim.Region.ClientStack.Linden
188 }; 207 };
189 } 208 }
190 209
191 public void Process() 210 public void Process(aPollRequest requestinfo)
192 { 211 {
193 Hashtable response; 212 Hashtable response;
194 Hashtable request = null;
195 213
196 try 214 UUID requestID = requestinfo.reqID;
197 {
198 lock (this.requests)
199 {
200 request = requests[0];
201 requests.RemoveAt(0);
202 }
203 }
204 catch
205 {
206 return;
207 }
208
209 UUID requestID = new UUID(request["RequestID"].ToString());
210 215
211 // If the avatar is gone, don't bother to get the texture 216 // If the avatar is gone, don't bother to get the texture
212 if (m_scene.GetScenePresence(Id) == null) 217 if (m_scene.GetScenePresence(Id) == null)
@@ -219,13 +224,15 @@ namespace OpenSim.Region.ClientStack.Linden
219 response["keepalive"] = false; 224 response["keepalive"] = false;
220 response["reusecontext"] = false; 225 response["reusecontext"] = false;
221 226
222 responses[requestID] = response; 227 lock (responses)
228 responses[requestID] = response;
229
223 return; 230 return;
224 } 231 }
225 232
226 response = m_getTextureHandler.Handle(request); 233 response = m_getTextureHandler.Handle(requestinfo.request);
227 234 lock (responses)
228 responses[requestID] = response; 235 responses[requestID] = response;
229 } 236 }
230 } 237 }
231 238
@@ -233,8 +240,7 @@ namespace OpenSim.Region.ClientStack.Linden
233 { 240 {
234 string capUrl = "/CAPS/" + UUID.Random() + "/"; 241 string capUrl = "/CAPS/" + UUID.Random() + "/";
235 242
236 // Register this as a poll service 243 // Register this as a poll service
237 // absurd large timeout to tune later to make a bit less than viewer
238 PollServiceTextureEventArgs args = new PollServiceTextureEventArgs(agentID, m_scene); 244 PollServiceTextureEventArgs args = new PollServiceTextureEventArgs(agentID, m_scene);
239 245
240 args.Type = PollServiceEventArgs.EventType.Texture; 246 args.Type = PollServiceEventArgs.EventType.Texture;
@@ -270,11 +276,10 @@ namespace OpenSim.Region.ClientStack.Linden
270 { 276 {
271 while (true) 277 while (true)
272 { 278 {
273 PollServiceTextureEventArgs args = m_queue.Dequeue(); 279 aPollRequest poolreq = m_queue.Dequeue();
274 280
275 args.Process(); 281 poolreq.thepoll.Process(poolreq);
276 } 282 }
277 } 283 }
278 } 284 }
279
280} 285}