fix PollServiceRequestManager

avinationmerge
UbitUmarov 2012-07-17 09:47:20 +01:00
parent 1ff498266c
commit 5874dfd342
1 changed files with 47 additions and 10 deletions

View File

@ -290,9 +290,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
foreach (PollServiceHttpRequest req in m_retryRequests) foreach (PollServiceHttpRequest req in m_retryRequests)
{ {
m_server.DoHTTPGruntWork( DoHTTPGruntWork(m_server,req,
req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
} }
} }
catch catch
@ -313,9 +312,8 @@ namespace OpenSim.Framework.Servers.HttpServer
try try
{ {
wreq = m_requests.Dequeue(0); wreq = m_requests.Dequeue(0);
m_server.DoHTTPGruntWork( DoHTTPGruntWork(m_server,wreq,
wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id), wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id));
new OSHttpResponse(new HttpResponse(wreq.HttpContext, wreq.Request), wreq.HttpContext));
} }
catch catch
{ {
@ -359,8 +357,7 @@ namespace OpenSim.Framework.Servers.HttpServer
try try
{ {
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
m_server.DoHTTPGruntWork(responsedata, DoHTTPGruntWork(m_server, req, responsedata);
new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
} }
catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
{ {
@ -375,8 +372,8 @@ namespace OpenSim.Framework.Servers.HttpServer
// if ((Environment.TickCount - req.RequestTime) > m_timeout) // if ((Environment.TickCount - req.RequestTime) > m_timeout)
if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
{ {
m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), DoHTTPGruntWork(m_server, req,
new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
} }
else else
{ {
@ -391,6 +388,46 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
} }
} }
// DoHTTPGruntWork changed, not sending response
// do the same work around as core
internal static void DoHTTPGruntWork(BaseHttpServer server, PollServiceHttpRequest req, Hashtable responsedata)
{
OSHttpResponse response
= new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext);
byte[] buffer = server.DoHTTPGruntWork(responsedata, response);
response.SendChunked = false;
response.ContentLength64 = buffer.Length;
response.ContentEncoding = Encoding.UTF8;
try
{
response.OutputStream.Write(buffer, 0, buffer.Length);
}
catch (Exception ex)
{
m_log.Warn(string.Format("[POLL SERVICE WORKER THREAD]: Error ", ex));
}
finally
{
//response.OutputStream.Close();
try
{
response.OutputStream.Flush();
response.Send();
//if (!response.KeepAlive && response.ReuseContext)
// response.FreeContext();
}
catch (Exception e)
{
m_log.Warn(String.Format("[POLL SERVICE WORKER THREAD]: Error ", e));
}
}
}
} }
} }