diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 2000279..1ccddd2 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,7 +151,12 @@ 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) |
155 | // this should never timeout | ||
156 | // each request must be processed and return a response | ||
157 | // noevents can possible be use for nice shutdown, but not sure now | ||
158 | // the execution will provide a proper response even if it fails | ||
159 | |||
146 | { | 160 | { |
147 | m_scene = scene; | 161 | m_scene = scene; |
148 | 162 | ||
@@ -164,13 +178,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
164 | 178 | ||
165 | Request = (x, y) => | 179 | Request = (x, y) => |
166 | { | 180 | { |
167 | y["RequestID"] = x.ToString(); | 181 | aPollRequest reqinfo = new aPollRequest(); |
168 | lock (requests) | 182 | reqinfo.thepoll = this; |
169 | requests.Add(y); | 183 | reqinfo.reqID = x; |
184 | reqinfo.request = y; | ||
170 | 185 | ||
171 | m_queue.Enqueue(this); | 186 | m_queue.Enqueue(reqinfo); |
172 | }; | 187 | }; |
173 | 188 | ||
189 | // this should never happen except possible on shutdown | ||
174 | NoEvents = (x, y) => | 190 | NoEvents = (x, y) => |
175 | { | 191 | { |
176 | lock (requests) | 192 | lock (requests) |
@@ -191,27 +207,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
191 | }; | 207 | }; |
192 | } | 208 | } |
193 | 209 | ||
194 | public void Process() | 210 | public void Process(aPollRequest requestinfo) |
195 | { | 211 | { |
196 | Hashtable response; | 212 | Hashtable response; |
197 | Hashtable request = null; | ||
198 | 213 | ||
199 | try | 214 | UUID requestID = requestinfo.reqID; |
200 | { | ||
201 | lock (requests) | ||
202 | { | ||
203 | request = requests[0]; | ||
204 | requests.RemoveAt(0); | ||
205 | } | ||
206 | } | ||
207 | catch | ||
208 | { | ||
209 | return; | ||
210 | } | ||
211 | |||
212 | UUID requestID = new UUID(request["RequestID"].ToString()); | ||
213 | 215 | ||
214 | // 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 |
217 | |||
215 | if (m_scene.GetScenePresence(Id) == null) | 218 | if (m_scene.GetScenePresence(Id) == null) |
216 | { | 219 | { |
217 | response = new Hashtable(); | 220 | response = new Hashtable(); |
@@ -228,7 +231,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
228 | return; | 231 | return; |
229 | } | 232 | } |
230 | 233 | ||
231 | response = m_getTextureHandler.Handle(request); | 234 | response = m_getTextureHandler.Handle(requestinfo.request); |
232 | lock (responses) | 235 | lock (responses) |
233 | responses[requestID] = response; | 236 | responses[requestID] = response; |
234 | } | 237 | } |
@@ -275,11 +278,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
275 | { | 278 | { |
276 | while (true) | 279 | while (true) |
277 | { | 280 | { |
278 | PollServiceTextureEventArgs args = m_queue.Dequeue(); | 281 | aPollRequest poolreq = m_queue.Dequeue(); |
279 | 282 | ||
280 | args.Process(); | 283 | poolreq.thepoll.Process(poolreq); |
281 | } | 284 | } |
282 | } | 285 | } |
283 | } | 286 | } |
284 | |||
285 | } | 287 | } |