diff options
author | Justin Clark-Casey (justincc) | 2013-07-15 23:28:02 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-07-15 23:28:02 +0100 |
commit | eb14e5a1756726b1f296591bb1ac385e4b1372d7 (patch) | |
tree | 6a7e5e7489785729a2487a0245e0c7e3a9ee99bd /OpenSim/Server | |
parent | Add request received/handling stats for caps which are served by http poll ha... (diff) | |
parent | Revert "Puts RequestImage (UDP) back to asyn -- CPU spike hunt" (diff) | |
download | opensim-SC_OLD-eb14e5a1756726b1f296591bb1ac385e4b1372d7.zip opensim-SC_OLD-eb14e5a1756726b1f296591bb1ac385e4b1372d7.tar.gz opensim-SC_OLD-eb14e5a1756726b1f296591bb1ac385e4b1372d7.tar.bz2 opensim-SC_OLD-eb14e5a1756726b1f296591bb1ac385e4b1372d7.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Server')
-rw-r--r-- | OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 78 |
1 files changed, 15 insertions, 63 deletions
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 40a34c6..4ac477f 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -27,11 +27,13 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Specialized; | ||
30 | using System.IO; | 31 | using System.IO; |
31 | using System.IO.Compression; | 32 | using System.IO.Compression; |
32 | using System.Reflection; | 33 | using System.Reflection; |
33 | using System.Net; | 34 | using System.Net; |
34 | using System.Text; | 35 | using System.Text; |
36 | using System.Web; | ||
35 | 37 | ||
36 | using OpenSim.Server.Base; | 38 | using OpenSim.Server.Base; |
37 | using OpenSim.Server.Handlers.Base; | 39 | using OpenSim.Server.Handlers.Base; |
@@ -90,14 +92,13 @@ namespace OpenSim.Server.Handlers.Simulation | |||
90 | 92 | ||
91 | // Next, let's parse the verb | 93 | // Next, let's parse the verb |
92 | string method = (string)request["http-method"]; | 94 | string method = (string)request["http-method"]; |
93 | if (method.Equals("GET")) | 95 | if (method.Equals("DELETE")) |
94 | { | 96 | { |
95 | DoAgentGet(request, responsedata, agentID, regionID); | 97 | string auth_token = string.Empty; |
96 | return responsedata; | 98 | if (request.ContainsKey("auth")) |
97 | } | 99 | auth_token = request["auth"].ToString(); |
98 | else if (method.Equals("DELETE")) | 100 | |
99 | { | 101 | DoAgentDelete(request, responsedata, agentID, action, regionID, auth_token); |
100 | DoAgentDelete(request, responsedata, agentID, action, regionID); | ||
101 | return responsedata; | 102 | return responsedata; |
102 | } | 103 | } |
103 | else if (method.Equals("QUERYACCESS")) | 104 | else if (method.Equals("QUERYACCESS")) |
@@ -107,7 +108,7 @@ namespace OpenSim.Server.Handlers.Simulation | |||
107 | } | 108 | } |
108 | else | 109 | else |
109 | { | 110 | { |
110 | m_log.InfoFormat("[AGENT HANDLER]: method {0} not supported in agent message (caller is {1})", method, Util.GetCallerIP(request)); | 111 | m_log.ErrorFormat("[AGENT HANDLER]: method {0} not supported in agent message {1} (caller is {2})", method, (string)request["uri"], Util.GetCallerIP(request)); |
111 | responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; | 112 | responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; |
112 | responsedata["str_response_string"] = "Method not allowed"; | 113 | responsedata["str_response_string"] = "Method not allowed"; |
113 | 114 | ||
@@ -156,61 +157,12 @@ namespace OpenSim.Server.Handlers.Simulation | |||
156 | // Console.WriteLine("str_response_string [{0}]", responsedata["str_response_string"]); | 157 | // Console.WriteLine("str_response_string [{0}]", responsedata["str_response_string"]); |
157 | } | 158 | } |
158 | 159 | ||
159 | protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) | 160 | protected void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID, string auth_token) |
160 | { | 161 | { |
161 | if (m_SimulationService == null) | 162 | if (string.IsNullOrEmpty(action)) |
162 | { | 163 | m_log.DebugFormat("[AGENT HANDLER]: >>> DELETE <<< RegionID: {0}; from: {1}; auth_code: {2}", regionID, Util.GetCallerIP(request), auth_token); |
163 | m_log.Debug("[AGENT HANDLER]: Agent GET called. Harmless but useless."); | ||
164 | responsedata["content_type"] = "application/json"; | ||
165 | responsedata["int_response_code"] = HttpStatusCode.NotImplemented; | ||
166 | responsedata["str_response_string"] = string.Empty; | ||
167 | |||
168 | return; | ||
169 | } | ||
170 | |||
171 | GridRegion destination = new GridRegion(); | ||
172 | destination.RegionID = regionID; | ||
173 | |||
174 | IAgentData agent = null; | ||
175 | bool result = m_SimulationService.RetrieveAgent(destination, id, out agent); | ||
176 | OSDMap map = null; | ||
177 | if (result) | ||
178 | { | ||
179 | if (agent != null) // just to make sure | ||
180 | { | ||
181 | map = agent.Pack(); | ||
182 | string strBuffer = ""; | ||
183 | try | ||
184 | { | ||
185 | strBuffer = OSDParser.SerializeJsonString(map); | ||
186 | } | ||
187 | catch (Exception e) | ||
188 | { | ||
189 | m_log.WarnFormat("[AGENT HANDLER]: Exception thrown on serialization of DoAgentGet: {0}", e.Message); | ||
190 | responsedata["int_response_code"] = HttpStatusCode.InternalServerError; | ||
191 | // ignore. buffer will be empty, caller should check. | ||
192 | } | ||
193 | |||
194 | responsedata["content_type"] = "application/json"; | ||
195 | responsedata["int_response_code"] = HttpStatusCode.OK; | ||
196 | responsedata["str_response_string"] = strBuffer; | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | responsedata["int_response_code"] = HttpStatusCode.InternalServerError; | ||
201 | responsedata["str_response_string"] = "Internal error"; | ||
202 | } | ||
203 | } | ||
204 | else | 164 | else |
205 | { | 165 | m_log.DebugFormat("[AGENT HANDLER]: Release {0} to RegionID: {1}", id, regionID); |
206 | responsedata["int_response_code"] = HttpStatusCode.NotFound; | ||
207 | responsedata["str_response_string"] = "Not Found"; | ||
208 | } | ||
209 | } | ||
210 | |||
211 | protected void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID) | ||
212 | { | ||
213 | m_log.Debug(" >>> DoDelete action:" + action + "; RegionID:" + regionID); | ||
214 | 166 | ||
215 | GridRegion destination = new GridRegion(); | 167 | GridRegion destination = new GridRegion(); |
216 | destination.RegionID = regionID; | 168 | destination.RegionID = regionID; |
@@ -218,12 +170,12 @@ namespace OpenSim.Server.Handlers.Simulation | |||
218 | if (action.Equals("release")) | 170 | if (action.Equals("release")) |
219 | ReleaseAgent(regionID, id); | 171 | ReleaseAgent(regionID, id); |
220 | else | 172 | else |
221 | Util.FireAndForget(delegate { m_SimulationService.CloseAgent(destination, id); }); | 173 | Util.FireAndForget(delegate { m_SimulationService.CloseAgent(destination, id, auth_token); }); |
222 | 174 | ||
223 | responsedata["int_response_code"] = HttpStatusCode.OK; | 175 | responsedata["int_response_code"] = HttpStatusCode.OK; |
224 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); | 176 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); |
225 | 177 | ||
226 | m_log.DebugFormat("[AGENT HANDLER]: Agent {0} Released/Deleted from region {1}", id, regionID); | 178 | //m_log.DebugFormat("[AGENT HANDLER]: Agent {0} Released/Deleted from region {1}", id, regionID); |
227 | } | 179 | } |
228 | 180 | ||
229 | protected virtual void ReleaseAgent(UUID regionID, UUID id) | 181 | protected virtual void ReleaseAgent(UUID regionID, UUID id) |