From 2d02405186841d5aeea30b608d106212f5fee1c3 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 23 Sep 2012 23:16:25 +0200
Subject: Change the poll service to use a thread pool for replies to make sure
the event queues aren't blocked by other traffic.
---
.../HttpServer/PollServiceRequestManager.cs | 45 ++++++++++++++++++----
prebuild.xml | 1 +
2 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index db088e7..c13c65b 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -33,6 +33,7 @@ using log4net;
using HttpServer;
using OpenSim.Framework;
using OpenSim.Framework.Monitoring;
+using Amib.Threading;
/*
@@ -185,6 +186,8 @@ namespace OpenSim.Framework.Servers.HttpServer
private bool m_running = true;
private int slowCount = 0;
+ private SmartThreadPool m_threadPool = new SmartThreadPool(20000, 12, 2);
+
// private int m_timeout = 1000; // increase timeout 250; now use the event one
public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
@@ -353,18 +356,46 @@ namespace OpenSim.Framework.Servers.HttpServer
continue;
}
- try
+ // "Normal" means the viewer evebt queue. We need to push these out fast.
+ // Process them inline. The rest go to the thread pool.
+ if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Normal)
{
- Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
- DoHTTPGruntWork(m_server, req, responsedata);
+ try
+ {
+ Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
+ DoHTTPGruntWork(m_server, req, responsedata);
+ }
+ catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
+ {
+ // Ignore it, no need to reply
+ }
+ finally
+ {
+ str.Close();
+ }
}
- catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
+ else
{
- // Ignore it, no need to reply
+ m_threadPool.QueueWorkItem(x =>
+ {
+ try
+ {
+ Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
+ DoHTTPGruntWork(m_server, req, responsedata);
+ }
+ catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
+ {
+ // Ignore it, no need to reply
+ }
+ finally
+ {
+ str.Close();
+ }
+
+ return null;
+ }, null);
}
- str.Close();
-
}
else
{
diff --git a/prebuild.xml b/prebuild.xml
index 05b36d0..afcae1c 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -162,6 +162,7 @@
+
--
cgit v1.1