From 48fc4ee059bea6c655686ee3ba7d2ff81b37dc4f Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 31 Mar 2008 17:34:32 +0000 Subject: * Log exceptions which make it up to the top of the http request frame, rather than having them disappear off into the ether --- .../Communications/InventoryServiceBase.cs | 52 ++++----- OpenSim/Framework/Servers/BaseHttpServer.cs | 122 +++++++++++---------- 2 files changed, 88 insertions(+), 86 deletions(-) (limited to 'OpenSim') 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 // See IInventoryServices public List GetInventorySkeleton(LLUUID userId) { - try + m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); + + InventoryFolderBase rootFolder = RequestRootFolder(userId); + + // Agent is completely new and has no inventory structure yet. + if (null == rootFolder) { - m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); - - List userFolders = new List(); - - InventoryFolderBase rootFolder = RequestRootFolder(userId); - - // Agent is completely new and has no inventory structure yet. - if (null == rootFolder) - { - return null; - } - - userFolders.Add(rootFolder); - - foreach (KeyValuePair plugin in m_plugins) - { - IList folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); - userFolders.AddRange(folders); - } - - // foreach (InventoryFolderBase folder in userFolders) - // { - // m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); - // } - - return userFolders; + return null; } - catch (Exception e) + + List userFolders = new List(); + userFolders.Add(rootFolder); + + foreach (KeyValuePair plugin in m_plugins) { - m_log.ErrorFormat("GetInventorySkeleton() exception {0}", e); - } + IList folders = plugin.Value.getFolderHierarchy(rootFolder.folderID); + userFolders.AddRange(folders); + } - return null; +// foreach (InventoryFolderBase folder in userFolders) +// { +// m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); +// } + + return userFolders; } // 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 return true; } + /// + /// Handle an individual http request. This method is given to a worker in the thread pool. + /// + /// public virtual void HandleRequest(Object stateinfo) { - HttpListenerContext context = (HttpListenerContext) stateinfo; - - HttpListenerRequest request = context.Request; - HttpListenerResponse response = context.Response; - - response.KeepAlive = false; - response.SendChunked = false; - - string path = request.RawUrl; - string handlerKey = GetHandlerKey(request.HttpMethod, path); - - IRequestHandler requestHandler; - - if (TryGetStreamHandler(handlerKey, out requestHandler)) + // If we don't catch the exception here it will just disappear into the thread pool and we'll be none the wiser + try { - // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. - byte[] buffer; - if (requestHandler is IStreamedRequestHandler) + HttpListenerContext context = (HttpListenerContext) stateinfo; + + HttpListenerRequest request = context.Request; + HttpListenerResponse response = context.Response; + + response.KeepAlive = false; + response.SendChunked = false; + + string path = request.RawUrl; + string handlerKey = GetHandlerKey(request.HttpMethod, path); + + IRequestHandler requestHandler; + + if (TryGetStreamHandler(handlerKey, out requestHandler)) { - IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; - buffer = streamedRequestHandler.Handle(path, request.InputStream); + // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. + byte[] buffer; + if (requestHandler is IStreamedRequestHandler) + { + IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; + buffer = streamedRequestHandler.Handle(path, request.InputStream); + } + else + { + IStreamHandler streamHandler = (IStreamHandler) requestHandler; + + using (MemoryStream memoryStream = new MemoryStream()) + { + streamHandler.Handle(path, request.InputStream, memoryStream); + memoryStream.Flush(); + buffer = memoryStream.ToArray(); + } + } + + request.InputStream.Close(); + response.ContentType = requestHandler.ContentType; + response.ContentLength64 = buffer.LongLength; + + try + { + response.OutputStream.Write(buffer, 0, buffer.Length); + response.OutputStream.Close(); + } + catch (HttpListenerException) + { + m_log.InfoFormat("[BASE HTTP SERVER] Http request abnormally terminated."); + } } else { - IStreamHandler streamHandler = (IStreamHandler) requestHandler; - - using (MemoryStream memoryStream = new MemoryStream()) + switch (request.ContentType) { - streamHandler.Handle(path, request.InputStream, memoryStream); - memoryStream.Flush(); - buffer = memoryStream.ToArray(); + case null: + case "text/html": + HandleHTTPRequest(request, response); + break; + case "application/xml+llsd": + HandleLLSDRequests(request, response); + break; + case "text/xml": + case "application/xml": + default: + HandleXmlRpcRequests(request, response); + break; } } - - request.InputStream.Close(); - response.ContentType = requestHandler.ContentType; - response.ContentLength64 = buffer.LongLength; - - try - { - response.OutputStream.Write(buffer, 0, buffer.Length); - response.OutputStream.Close(); - } - catch (HttpListenerException) - { - m_log.InfoFormat("[BASEHTTPSERVER] Http request abnormally terminated."); - } } - else + catch (Exception e) { - switch (request.ContentType) - { - case null: - case "text/html": - HandleHTTPRequest(request, response); - break; - case "application/xml+llsd": - HandleLLSDRequests(request, response); - break; - case "text/xml": - case "application/xml": - default: - HandleXmlRpcRequests(request, response); - break; - } + m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); } } -- cgit v1.1