diff options
Merge branch 'ubitwork' into avination
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index b77ead3..2475b1f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |||
@@ -60,11 +60,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
60 | 60 | ||
61 | private WebFetchInvDescHandler m_webFetchHandler; | 61 | private WebFetchInvDescHandler m_webFetchHandler; |
62 | 62 | ||
63 | private ManualResetEvent m_ev = new ManualResetEvent(true); | 63 | // private ManualResetEvent m_ev = new ManualResetEvent(true); |
64 | private object m_lock = new object(); | 64 | private object m_lock = new object(); |
65 | 65 | ||
66 | private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); | 66 | private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); |
67 | private Dictionary<UUID, Hashtable> m_requests = new Dictionary<UUID, Hashtable>(); | 67 | private Dictionary<UUID, Hashtable> m_requests = new Dictionary<UUID, Hashtable>(); |
68 | bool m_busy = false; | ||
68 | 69 | ||
69 | #region ISharedRegionModule Members | 70 | #region ISharedRegionModule Members |
70 | 71 | ||
@@ -116,7 +117,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
116 | string capUrl = "/CAPS/" + UUID.Random() + "/"; | 117 | string capUrl = "/CAPS/" + UUID.Random() + "/"; |
117 | 118 | ||
118 | // Register this as a poll service | 119 | // Register this as a poll service |
120 | // absurd large timeout to tune later to make a bit less than viewer | ||
119 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, agentID, 300000); | 121 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, agentID, 300000); |
122 | |||
120 | args.Type = PollServiceEventArgs.EventType.Inventory; | 123 | args.Type = PollServiceEventArgs.EventType.Inventory; |
121 | MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); | 124 | MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); |
122 | 125 | ||
@@ -133,6 +136,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
133 | caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); | 136 | caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); |
134 | 137 | ||
135 | m_capsDict[agentID] = capUrl; | 138 | m_capsDict[agentID] = capUrl; |
139 | |||
140 | m_busy = false; | ||
136 | } | 141 | } |
137 | 142 | ||
138 | private void DeregisterCaps(UUID agentID, Caps caps) | 143 | private void DeregisterCaps(UUID agentID, Caps caps) |
@@ -149,25 +154,30 @@ namespace OpenSim.Region.ClientStack.Linden | |||
149 | public void HttpRequestHandler(UUID requestID, Hashtable request) | 154 | public void HttpRequestHandler(UUID requestID, Hashtable request) |
150 | { | 155 | { |
151 | // m_log.DebugFormat("[FETCH2]: Received request {0}", requestID); | 156 | // m_log.DebugFormat("[FETCH2]: Received request {0}", requestID); |
152 | m_requests[requestID] = request; | 157 | lock(m_lock) |
158 | m_requests[requestID] = request; | ||
153 | } | 159 | } |
154 | 160 | ||
155 | private bool HasEvents(UUID requestID, UUID sessionID) | 161 | private bool HasEvents(UUID requestID, UUID sessionID) |
156 | { | 162 | { |
157 | lock (m_lock) | 163 | lock (m_lock) |
158 | { | 164 | { |
165 | /* | ||
159 | if (m_ev.WaitOne(0)) | 166 | if (m_ev.WaitOne(0)) |
160 | { | 167 | { |
161 | m_ev.Reset(); | 168 | m_ev.Reset(); |
162 | return true; | 169 | return true; |
163 | } | 170 | } |
164 | return false; | 171 | return false; |
172 | */ | ||
173 | return !m_busy; | ||
165 | } | 174 | } |
166 | } | 175 | } |
167 | 176 | ||
168 | private Hashtable NoEvents(UUID requestID, UUID sessionID) | 177 | private Hashtable NoEvents(UUID requestID, UUID sessionID) |
169 | { | 178 | { |
170 | m_requests.Remove(requestID); | 179 | lock(m_lock) |
180 | m_requests.Remove(requestID); | ||
171 | 181 | ||
172 | Hashtable response = new Hashtable(); | 182 | Hashtable response = new Hashtable(); |
173 | 183 | ||
@@ -177,11 +187,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
177 | response["keepalive"] = false; | 187 | response["keepalive"] = false; |
178 | response["reusecontext"] = false; | 188 | response["reusecontext"] = false; |
179 | 189 | ||
190 | lock (m_lock) | ||
191 | m_busy = false; | ||
192 | |||
180 | return response; | 193 | return response; |
181 | } | 194 | } |
182 | 195 | ||
183 | private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) | 196 | private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) |
184 | { | 197 | { |
198 | lock (m_lock) | ||
199 | m_busy = true; | ||
200 | |||
185 | Hashtable response = new Hashtable(); | 201 | Hashtable response = new Hashtable(); |
186 | 202 | ||
187 | response["int_response_code"] = 500; | 203 | response["int_response_code"] = 500; |
@@ -192,20 +208,24 @@ namespace OpenSim.Region.ClientStack.Linden | |||
192 | 208 | ||
193 | try | 209 | try |
194 | { | 210 | { |
211 | |||
195 | Hashtable requestHash; | 212 | Hashtable requestHash; |
196 | if (!m_requests.TryGetValue(requestID, out requestHash)) | 213 | lock (m_lock) |
197 | { | 214 | { |
198 | lock (m_lock) | 215 | if (!m_requests.TryGetValue(requestID, out requestHash)) |
199 | m_ev.Set(); | 216 | { |
200 | response["str_response_string"] = "Invalid request"; | 217 | m_busy = false; |
201 | return response; | 218 | // m_ev.Set(); |
219 | response["str_response_string"] = "Invalid request"; | ||
220 | return response; | ||
221 | } | ||
222 | m_requests.Remove(requestID); | ||
202 | } | 223 | } |
203 | 224 | ||
204 | // m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID); | 225 | // m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID); |
205 | 226 | ||
206 | string reply = m_webFetchHandler.FetchInventoryDescendentsRequest(requestHash["body"].ToString(), String.Empty, String.Empty, null, null); | 227 | string reply = m_webFetchHandler.FetchInventoryDescendentsRequest(requestHash["body"].ToString(), String.Empty, String.Empty, null, null); |
207 | 228 | ||
208 | m_requests.Remove(requestID); | ||
209 | 229 | ||
210 | response["int_response_code"] = 200; | 230 | response["int_response_code"] = 200; |
211 | response["str_response_string"] = reply; | 231 | response["str_response_string"] = reply; |
@@ -213,7 +233,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
213 | finally | 233 | finally |
214 | { | 234 | { |
215 | lock (m_lock) | 235 | lock (m_lock) |
216 | m_ev.Set(); | 236 | // m_ev.Set(); |
237 | m_busy = false; | ||
217 | } | 238 | } |
218 | 239 | ||
219 | return response; | 240 | return response; |