From 8a9d1689284a00f27a38ae45535b8b68bf814852 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 26 Aug 2009 14:46:10 +0100 Subject: Add try/catch around EQ request processing Fixes Mantis #4061 --- .../Servers/HttpServer/PollServiceWorkerThread.cs | 43 ++++++++++++++-------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs index d8cbeac..41fb376 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs @@ -59,6 +59,8 @@ using System.IO; using System.Text; using HttpServer; using OpenMetaverse; +using System.Reflection; +using log4net; namespace OpenSim.Framework.Servers.HttpServer { @@ -66,6 +68,10 @@ namespace OpenSim.Framework.Servers.HttpServer public class PollServiceWorkerThread { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + public event ReQueuePollServiceItem ReQueue; private readonly BaseHttpServer m_server; @@ -92,31 +98,36 @@ namespace OpenSim.Framework.Servers.HttpServer while (m_running) { PollServiceHttpRequest req = m_request.Dequeue(); - if (req.PollServiceArgs.HasEvents(req.PollServiceArgs.Id)) + try { - StreamReader str = new StreamReader(req.Request.Body); - - Hashtable responsedata = req.PollServiceArgs.GetEvents(req.PollServiceArgs.Id, str.ReadToEnd()); - m_server.DoHTTPGruntWork(responsedata, - new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); - } - else - { - if ((Environment.TickCount - req.RequestTime) > m_timeout) + if (req.PollServiceArgs.HasEvents(req.PollServiceArgs.Id)) { - m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), + StreamReader str = new StreamReader(req.Request.Body); + + Hashtable responsedata = req.PollServiceArgs.GetEvents(req.PollServiceArgs.Id, str.ReadToEnd()); + m_server.DoHTTPGruntWork(responsedata, new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); } else { - ReQueuePollServiceItem reQueueItem = ReQueue; - if (reQueueItem != null) - reQueueItem(req); + if ((Environment.TickCount - req.RequestTime) > m_timeout) + { + m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), + new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); + } + else + { + ReQueuePollServiceItem reQueueItem = ReQueue; + if (reQueueItem != null) + reQueueItem(req); + } } } + catch (Exception e) + { + m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); + } } - - } internal void Enqueue(PollServiceHttpRequest pPollServiceHttpRequest) -- cgit v1.1