Make OpenSim.Framework.Servers.HttpServer rely on OpenSim.Framework instead of the other way around.

This is necessary so that code in HttpServer can use framework facilities such as the thread watchdog for monitoring purposes.
Doing this shuffle meant that MainServer was moved into OpenSim/Framework/Servers
Also had to make OpenSim.Framework.Console rely on OpenSim.Framework rather than the other way around since it in turn relies on HttpServer
MainConsole and some new interfaces had to be moved into OpenSim/Framework to allow this.  This can be reverted if parts of OpenSim.Framework stop relying on console presence (cheifly RegionInfo)
This commit is contained in:
Justin Clark-Casey (justincc)
2011-10-25 20:24:21 +01:00
parent e14cb45b9b
commit 8a0a78cbcc
44 changed files with 318 additions and 140 deletions

View File

@@ -49,7 +49,7 @@ namespace OpenSim.Framework.Servers.HttpServer
/// <summary>
/// Add a handler for an HTTP request.
/// </summary>
///
/// <remarks>
/// This handler can actually be invoked either as
///
/// http://<hostname>:<port>/?method=<methodName>
@@ -70,7 +70,7 @@ namespace OpenSim.Framework.Servers.HttpServer
/// In addition, the handler invoked by the HTTP server for any request is the one when best matches the request
/// URI. So if a handler for "/myapp/" is registered and a request for "/myapp/page" is received, then
/// the "/myapp/" handler is invoked if no "/myapp/page" handler exists.
///
/// </remarks>
/// <param name="methodName"></param>
/// <param name="handler"></param>
/// <returns>

View File

@@ -31,6 +31,7 @@ using System.Threading;
using System.Reflection;
using log4net;
using HttpServer;
using OpenSim.Framework;
namespace OpenSim.Framework.Servers.HttpServer
{
@@ -54,21 +55,25 @@ namespace OpenSim.Framework.Servers.HttpServer
m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount];
//startup worker threads
for (uint i=0;i<m_WorkerThreadCount;i++)
for (uint i = 0; i < m_WorkerThreadCount; i++)
{
m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, pTimeout);
m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent;
m_workerThreads[i] = new Thread(m_PollServiceWorkerThreads[i].ThreadStart);
m_workerThreads[i].Name = String.Format("PollServiceWorkerThread{0}",i);
//Can't add to thread Tracker here Referencing OpenSim.Framework creates circular reference
m_workerThreads[i].Start();
// m_workerThreads[i]
// = Watchdog.StartThread(
// m_PollServiceWorkerThreads[i].ThreadStart,
// String.Format("PollServiceWorkerThread{0}", i),
// ThreadPriority.Normal,
// false);
}
//start watcher threads
m_watcherThread = new Thread(ThreadStart);
m_watcherThread.Name = "PollServiceWatcherThread";
m_watcherThread.Start();
m_watcherThread
= Watchdog.StartThread(
this.ThreadStart,
"PollServiceWatcherThread",
ThreadPriority.Normal,
false);
}
internal void ReQueueEvent(PollServiceHttpRequest req)
@@ -83,10 +88,11 @@ namespace OpenSim.Framework.Servers.HttpServer
m_requests.Enqueue(req);
}
public void ThreadStart(object o)
public void ThreadStart()
{
while (m_running)
{
Watchdog.UpdateThread();
ProcessQueuedRequests();
Thread.Sleep(1000);
}
@@ -107,7 +113,7 @@ namespace OpenSim.Framework.Servers.HttpServer
for (int tc = 0; tc < m_WorkerThreadCount && m_requests.Count > 0; tc++)
{
//Loop over number of requests each thread handles.
for (int i=0;i<reqperthread && m_requests.Count > 0;i++)
for (int i = 0; i < reqperthread && m_requests.Count > 0; i++)
{
try
{
@@ -125,14 +131,14 @@ namespace OpenSim.Framework.Servers.HttpServer
}
~PollServiceRequestManager()
{
foreach (object o in m_requests)
{
PollServiceHttpRequest req = (PollServiceHttpRequest) o;
m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
m_server.DoHTTPGruntWork(
req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id),
new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
}
m_requests.Clear();
@@ -144,4 +150,4 @@ namespace OpenSim.Framework.Servers.HttpServer
m_running = false;
}
}
}
}

View File

@@ -59,7 +59,7 @@ namespace OpenSim.Framework.Servers.HttpServer
m_timeout = pTimeout;
}
public void ThreadStart(object o)
public void ThreadStart()
{
Run();
}