diff options
author | Justin Clarke Casey | 2008-03-31 17:34:32 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-03-31 17:34:32 +0000 |
commit | 48fc4ee059bea6c655686ee3ba7d2ff81b37dc4f (patch) | |
tree | dd91b7e00eae88b44246ec4719bb57336c87b5a2 | |
parent | * Fix problem where inventory code throws a swallowed exception on grid mode ... (diff) | |
download | opensim-SC-48fc4ee059bea6c655686ee3ba7d2ff81b37dc4f.zip opensim-SC-48fc4ee059bea6c655686ee3ba7d2ff81b37dc4f.tar.gz opensim-SC-48fc4ee059bea6c655686ee3ba7d2ff81b37dc4f.tar.bz2 opensim-SC-48fc4ee059bea6c655686ee3ba7d2ff81b37dc4f.tar.xz |
* Log exceptions which make it up to the top of the http request frame, rather than having them disappear off into the ether
-rw-r--r-- | OpenSim/Framework/Communications/InventoryServiceBase.cs | 52 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/BaseHttpServer.cs | 122 |
2 files changed, 88 insertions, 86 deletions
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 3187215..f38abd3 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs | |||
@@ -79,41 +79,31 @@ namespace OpenSim.Framework.Communications | |||
79 | // See IInventoryServices | 79 | // See IInventoryServices |
80 | public List<InventoryFolderBase> GetInventorySkeleton(LLUUID userId) | 80 | public List<InventoryFolderBase> GetInventorySkeleton(LLUUID userId) |
81 | { | 81 | { |
82 | try | 82 | m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); |
83 | |||
84 | InventoryFolderBase rootFolder = RequestRootFolder(userId); | ||
85 | |||
86 | // Agent is completely new and has no inventory structure yet. | ||
87 | if (null == rootFolder) | ||
83 | { | 88 | { |
84 | m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); | 89 | return null; |
85 | |||
86 | List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>(); | ||
87 | |||
88 | InventoryFolderBase rootFolder = RequestRootFolder(userId); | ||
89 | |||
90 | // Agent is completely new and has no inventory structure yet. | ||
91 | if (null == rootFolder) | ||
92 | { | ||
93 | return null; | ||
94 | } | ||
95 | |||
96 | userFolders.Add(rootFolder); | ||
97 | |||
98 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | ||
99 | { | ||
100 | IList<InventoryFolderBase> folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); | ||
101 | userFolders.AddRange(folders); | ||
102 | } | ||
103 | |||
104 | // foreach (InventoryFolderBase folder in userFolders) | ||
105 | // { | ||
106 | // m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); | ||
107 | // } | ||
108 | |||
109 | return userFolders; | ||
110 | } | 90 | } |
111 | catch (Exception e) | 91 | |
92 | List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>(); | ||
93 | userFolders.Add(rootFolder); | ||
94 | |||
95 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | ||
112 | { | 96 | { |
113 | m_log.ErrorFormat("GetInventorySkeleton() exception {0}", e); | 97 | IList<InventoryFolderBase> folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); |
114 | } | 98 | userFolders.AddRange(folders); |
99 | } | ||
115 | 100 | ||
116 | return null; | 101 | // foreach (InventoryFolderBase folder in userFolders) |
102 | // { | ||
103 | // m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); | ||
104 | // } | ||
105 | |||
106 | return userFolders; | ||
117 | } | 107 | } |
118 | 108 | ||
119 | // See IInventoryServices | 109 | // See IInventoryServices |
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index 0f6d79b..289b122 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs | |||
@@ -123,73 +123,85 @@ namespace OpenSim.Framework.Servers | |||
123 | return true; | 123 | return true; |
124 | } | 124 | } |
125 | 125 | ||
126 | /// <summary> | ||
127 | /// Handle an individual http request. This method is given to a worker in the thread pool. | ||
128 | /// </summary> | ||
129 | /// <param name="stateinfo"></param> | ||
126 | public virtual void HandleRequest(Object stateinfo) | 130 | public virtual void HandleRequest(Object stateinfo) |
127 | { | 131 | { |
128 | HttpListenerContext context = (HttpListenerContext) stateinfo; | 132 | // If we don't catch the exception here it will just disappear into the thread pool and we'll be none the wiser |
129 | 133 | try | |
130 | HttpListenerRequest request = context.Request; | ||
131 | HttpListenerResponse response = context.Response; | ||
132 | |||
133 | response.KeepAlive = false; | ||
134 | response.SendChunked = false; | ||
135 | |||
136 | string path = request.RawUrl; | ||
137 | string handlerKey = GetHandlerKey(request.HttpMethod, path); | ||
138 | |||
139 | IRequestHandler requestHandler; | ||
140 | |||
141 | if (TryGetStreamHandler(handlerKey, out requestHandler)) | ||
142 | { | 134 | { |
143 | // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. | 135 | HttpListenerContext context = (HttpListenerContext) stateinfo; |
144 | byte[] buffer; | 136 | |
145 | if (requestHandler is IStreamedRequestHandler) | 137 | HttpListenerRequest request = context.Request; |
138 | HttpListenerResponse response = context.Response; | ||
139 | |||
140 | response.KeepAlive = false; | ||
141 | response.SendChunked = false; | ||
142 | |||
143 | string path = request.RawUrl; | ||
144 | string handlerKey = GetHandlerKey(request.HttpMethod, path); | ||
145 | |||
146 | IRequestHandler requestHandler; | ||
147 | |||
148 | if (TryGetStreamHandler(handlerKey, out requestHandler)) | ||
146 | { | 149 | { |
147 | IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; | 150 | // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. |
148 | buffer = streamedRequestHandler.Handle(path, request.InputStream); | 151 | byte[] buffer; |
152 | if (requestHandler is IStreamedRequestHandler) | ||
153 | { | ||
154 | IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; | ||
155 | buffer = streamedRequestHandler.Handle(path, request.InputStream); | ||
156 | } | ||
157 | else | ||
158 | { | ||
159 | IStreamHandler streamHandler = (IStreamHandler) requestHandler; | ||
160 | |||
161 | using (MemoryStream memoryStream = new MemoryStream()) | ||
162 | { | ||
163 | streamHandler.Handle(path, request.InputStream, memoryStream); | ||
164 | memoryStream.Flush(); | ||
165 | buffer = memoryStream.ToArray(); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | request.InputStream.Close(); | ||
170 | response.ContentType = requestHandler.ContentType; | ||
171 | response.ContentLength64 = buffer.LongLength; | ||
172 | |||
173 | try | ||
174 | { | ||
175 | response.OutputStream.Write(buffer, 0, buffer.Length); | ||
176 | response.OutputStream.Close(); | ||
177 | } | ||
178 | catch (HttpListenerException) | ||
179 | { | ||
180 | m_log.InfoFormat("[BASE HTTP SERVER] Http request abnormally terminated."); | ||
181 | } | ||
149 | } | 182 | } |
150 | else | 183 | else |
151 | { | 184 | { |
152 | IStreamHandler streamHandler = (IStreamHandler) requestHandler; | 185 | switch (request.ContentType) |
153 | |||
154 | using (MemoryStream memoryStream = new MemoryStream()) | ||
155 | { | 186 | { |
156 | streamHandler.Handle(path, request.InputStream, memoryStream); | 187 | case null: |
157 | memoryStream.Flush(); | 188 | case "text/html": |
158 | buffer = memoryStream.ToArray(); | 189 | HandleHTTPRequest(request, response); |
190 | break; | ||
191 | case "application/xml+llsd": | ||
192 | HandleLLSDRequests(request, response); | ||
193 | break; | ||
194 | case "text/xml": | ||
195 | case "application/xml": | ||
196 | default: | ||
197 | HandleXmlRpcRequests(request, response); | ||
198 | break; | ||
159 | } | 199 | } |
160 | } | 200 | } |
161 | |||
162 | request.InputStream.Close(); | ||
163 | response.ContentType = requestHandler.ContentType; | ||
164 | response.ContentLength64 = buffer.LongLength; | ||
165 | |||
166 | try | ||
167 | { | ||
168 | response.OutputStream.Write(buffer, 0, buffer.Length); | ||
169 | response.OutputStream.Close(); | ||
170 | } | ||
171 | catch (HttpListenerException) | ||
172 | { | ||
173 | m_log.InfoFormat("[BASEHTTPSERVER] Http request abnormally terminated."); | ||
174 | } | ||
175 | } | 201 | } |
176 | else | 202 | catch (Exception e) |
177 | { | 203 | { |
178 | switch (request.ContentType) | 204 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); |
179 | { | ||
180 | case null: | ||
181 | case "text/html": | ||
182 | HandleHTTPRequest(request, response); | ||
183 | break; | ||
184 | case "application/xml+llsd": | ||
185 | HandleLLSDRequests(request, response); | ||
186 | break; | ||
187 | case "text/xml": | ||
188 | case "application/xml": | ||
189 | default: | ||
190 | HandleXmlRpcRequests(request, response); | ||
191 | break; | ||
192 | } | ||
193 | } | 205 | } |
194 | } | 206 | } |
195 | 207 | ||