diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 82 |
1 files changed, 39 insertions, 43 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 4908c2c..0caeddf 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |||
@@ -52,6 +52,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
52 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 52 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
53 | public class WebFetchInvDescModule : INonSharedRegionModule | 53 | public class WebFetchInvDescModule : INonSharedRegionModule |
54 | { | 54 | { |
55 | struct aPollRequest | ||
56 | { | ||
57 | public PollServiceInventoryEventArgs thepoll; | ||
58 | public UUID reqID; | ||
59 | public Hashtable request; | ||
60 | } | ||
61 | |||
55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 62 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
56 | 63 | ||
57 | private Scene m_scene; | 64 | private Scene m_scene; |
@@ -64,8 +71,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
64 | private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); | 71 | private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); |
65 | private static Thread[] m_workerThreads = null; | 72 | private static Thread[] m_workerThreads = null; |
66 | 73 | ||
67 | private static OpenMetaverse.BlockingQueue<PollServiceInventoryEventArgs> m_queue = | 74 | private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue = |
68 | new OpenMetaverse.BlockingQueue<PollServiceInventoryEventArgs>(); | 75 | new OpenMetaverse.BlockingQueue<aPollRequest>(); |
69 | 76 | ||
70 | #region ISharedRegionModule Members | 77 | #region ISharedRegionModule Members |
71 | 78 | ||
@@ -131,49 +138,52 @@ namespace OpenSim.Region.ClientStack.Linden | |||
131 | ~WebFetchInvDescModule() | 138 | ~WebFetchInvDescModule() |
132 | { | 139 | { |
133 | foreach (Thread t in m_workerThreads) | 140 | foreach (Thread t in m_workerThreads) |
134 | t.Abort(); | 141 | Watchdog.AbortThread(t.ManagedThreadId); |
135 | } | 142 | } |
136 | 143 | ||
137 | private class PollServiceInventoryEventArgs : PollServiceEventArgs | 144 | private class PollServiceInventoryEventArgs : PollServiceEventArgs |
138 | { | 145 | { |
139 | private List<Hashtable> requests = | ||
140 | new List<Hashtable>(); | ||
141 | private Dictionary<UUID, Hashtable> responses = | 146 | private Dictionary<UUID, Hashtable> responses = |
142 | new Dictionary<UUID, Hashtable>(); | 147 | new Dictionary<UUID, Hashtable>(); |
143 | 148 | ||
144 | public PollServiceInventoryEventArgs(UUID pId) : | 149 | public PollServiceInventoryEventArgs(UUID pId) : |
145 | base(null, null, null, null, pId, 30000) | 150 | base(null, null, null, null, pId, int.MaxValue) |
146 | { | 151 | { |
147 | HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; | 152 | HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; |
148 | GetEvents = (x, y, s) => | 153 | GetEvents = (x, y) => |
149 | { | 154 | { |
150 | try | 155 | lock (responses) |
151 | { | ||
152 | return this.responses[x]; | ||
153 | } | ||
154 | finally | ||
155 | { | 156 | { |
156 | responses.Remove(x); | 157 | try |
158 | { | ||
159 | return responses[x]; | ||
160 | } | ||
161 | finally | ||
162 | { | ||
163 | responses.Remove(x); | ||
164 | } | ||
157 | } | 165 | } |
158 | }; | 166 | }; |
159 | 167 | ||
160 | Request = (x, y) => | 168 | Request = (x, y) => |
161 | { | 169 | { |
162 | y["RequestID"] = x.ToString(); | 170 | aPollRequest reqinfo = new aPollRequest(); |
163 | lock (this.requests) | 171 | reqinfo.thepoll = this; |
164 | this.requests.Add(y); | 172 | reqinfo.reqID = x; |
173 | reqinfo.request = y; | ||
165 | 174 | ||
166 | m_queue.Enqueue(this); | 175 | m_queue.Enqueue(reqinfo); |
167 | }; | 176 | }; |
168 | 177 | ||
169 | NoEvents = (x, y) => | 178 | NoEvents = (x, y) => |
170 | { | 179 | { |
171 | lock (this.requests) | 180 | /* |
181 | lock (requests) | ||
172 | { | 182 | { |
173 | Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); | 183 | Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); |
174 | requests.Remove(request); | 184 | requests.Remove(request); |
175 | } | 185 | } |
176 | 186 | */ | |
177 | Hashtable response = new Hashtable(); | 187 | Hashtable response = new Hashtable(); |
178 | 188 | ||
179 | response["int_response_code"] = 500; | 189 | response["int_response_code"] = 500; |
@@ -186,24 +196,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
186 | }; | 196 | }; |
187 | } | 197 | } |
188 | 198 | ||
189 | public void Process() | 199 | public void Process(aPollRequest requestinfo) |
190 | { | 200 | { |
191 | Hashtable request = null; | 201 | UUID requestID = requestinfo.reqID; |
192 | |||
193 | try | ||
194 | { | ||
195 | lock (this.requests) | ||
196 | { | ||
197 | request = requests[0]; | ||
198 | requests.RemoveAt(0); | ||
199 | } | ||
200 | } | ||
201 | catch | ||
202 | { | ||
203 | return; | ||
204 | } | ||
205 | |||
206 | UUID requestID = new UUID(request["RequestID"].ToString()); | ||
207 | 202 | ||
208 | Hashtable response = new Hashtable(); | 203 | Hashtable response = new Hashtable(); |
209 | 204 | ||
@@ -212,9 +207,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
212 | response["keepalive"] = false; | 207 | response["keepalive"] = false; |
213 | response["reusecontext"] = false; | 208 | response["reusecontext"] = false; |
214 | 209 | ||
215 | response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null); | 210 | response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest( |
211 | requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); | ||
216 | 212 | ||
217 | responses[requestID] = response; | 213 | lock (responses) |
214 | responses[requestID] = response; | ||
218 | } | 215 | } |
219 | } | 216 | } |
220 | 217 | ||
@@ -222,8 +219,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
222 | { | 219 | { |
223 | string capUrl = "/CAPS/" + UUID.Random() + "/"; | 220 | string capUrl = "/CAPS/" + UUID.Random() + "/"; |
224 | 221 | ||
225 | // Register this as a poll service | 222 | // Register this as a poll service |
226 | // absurd large timeout to tune later to make a bit less than viewer | ||
227 | PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); | 223 | PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); |
228 | 224 | ||
229 | args.Type = PollServiceEventArgs.EventType.Inventory; | 225 | args.Type = PollServiceEventArgs.EventType.Inventory; |
@@ -259,9 +255,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
259 | { | 255 | { |
260 | while (true) | 256 | while (true) |
261 | { | 257 | { |
262 | PollServiceInventoryEventArgs args = m_queue.Dequeue(); | 258 | aPollRequest poolreq = m_queue.Dequeue(); |
263 | 259 | ||
264 | args.Process(); | 260 | poolreq.thepoll.Process(poolreq); |
265 | } | 261 | } |
266 | } | 262 | } |
267 | } | 263 | } |