Merge branch 'master' into careminster

Conflicts:
	OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
	OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
	OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
This commit is contained in:
Melanie
2013-07-24 03:50:09 +01:00
31 changed files with 656 additions and 277 deletions

View File

@@ -58,7 +58,7 @@ namespace OpenSim.Framework
{
lock (m_queueSync)
{
if (m_queue.Count < 1 && m_pqueue.Count < 1)
while (m_queue.Count < 1 && m_pqueue.Count < 1)
{
Monitor.Wait(m_queueSync);
}
@@ -76,9 +76,10 @@ namespace OpenSim.Framework
{
lock (m_queueSync)
{
if (m_queue.Count < 1 && m_pqueue.Count < 1)
bool success = true;
while (m_queue.Count < 1 && m_pqueue.Count < 1 && success)
{
Monitor.Wait(m_queueSync, msTimeout);
success = Monitor.Wait(m_queueSync, msTimeout);
}
if (m_pqueue.Count > 0)
@@ -89,8 +90,17 @@ namespace OpenSim.Framework
}
}
/// <summary>
/// Indicate whether this queue contains the given item.
/// </summary>
/// <remarks>
/// This method is not thread-safe. Do not rely on the result without consistent external locking.
/// </remarks>
public bool Contains(T item)
{
if (m_queue.Count < 1 && m_pqueue.Count < 1)
return false;
lock (m_queueSync)
{
if (m_pqueue.Contains(item))
@@ -99,16 +109,28 @@ namespace OpenSim.Framework
}
}
/// <summary>
/// Return a count of the number of requests on this queue.
/// </summary>
/// <remarks>
/// This method is not thread-safe. Do not rely on the result without consistent external locking.
/// </remarks>
public int Count()
{
lock (m_queueSync)
{
return m_queue.Count+m_pqueue.Count;
}
return m_queue.Count + m_pqueue.Count;
}
/// <summary>
/// Return the array of items on this queue.
/// </summary>
/// <remarks>
/// This method is not thread-safe. Do not rely on the result without consistent external locking.
/// </remarks>
public T[] GetQueueArray()
{
if (m_queue.Count < 1 && m_pqueue.Count < 1)
return new T[0];
lock (m_queueSync)
{
return m_queue.ToArray();

View File

@@ -234,7 +234,7 @@ namespace OpenSim.Framework.Console
string uri = "/ReadResponses/" + sessionID.ToString() + "/";
m_Server.AddPollServiceHTTPHandler(
uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout
uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout
XmlDocument xmldoc = new XmlDocument();
XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,

View File

@@ -387,6 +387,8 @@ namespace OpenSim.Framework.Servers.HttpServer
if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs))
{
psEvArgs.RequestsReceived++;
PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request);
if (psEvArgs.Request != null)

View File

@@ -50,25 +50,39 @@ namespace OpenSim.Framework.Servers.HttpServer
public enum EventType : int
{
Normal = 0,
LongPoll = 0,
LslHttp = 1,
Inventory = 2,
Texture = 3,
Mesh = 4
}
public string Url { get; set; }
/// <summary>
/// Number of requests received for this poll service.
/// </summary>
public int RequestsReceived { get; set; }
/// <summary>
/// Number of requests handled by this poll service.
/// </summary>
public int RequestsHandled { get; set; }
public PollServiceEventArgs(
RequestMethod pRequest,
string pUrl,
HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,
UUID pId, int pTimeOutms)
{
Request = pRequest;
Url = pUrl;
HasEvents = pHasEvents;
GetEvents = pGetEvents;
NoEvents = pNoEvents;
Id = pId;
TimeOutms = pTimeOutms;
Type = EventType.Normal;
Type = EventType.LongPoll;
}
}
}

View File

@@ -26,13 +26,19 @@
*/
using System;
using System.Collections;
using System.Reflection;
using System.Text;
using HttpServer;
using log4net;
using OpenMetaverse;
namespace OpenSim.Framework.Servers.HttpServer
{
public class PollServiceHttpRequest
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public readonly PollServiceEventArgs PollServiceArgs;
public readonly IHttpClientContext HttpContext;
public readonly IHttpRequest Request;
@@ -48,5 +54,44 @@ namespace OpenSim.Framework.Servers.HttpServer
RequestTime = System.Environment.TickCount;
RequestID = UUID.Random();
}
internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata)
{
OSHttpResponse response
= new OSHttpResponse(new HttpResponse(HttpContext, Request), 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));
}
PollServiceArgs.RequestsHandled++;
}
}
}
}

View File

@@ -105,7 +105,7 @@ namespace OpenSim.Framework.Servers.HttpServer
{
if (m_running)
{
if (req.PollServiceArgs.Type != PollServiceEventArgs.EventType.Normal)
if (req.PollServiceArgs.Type != PollServiceEventArgs.EventType.LongPoll)
{
m_requests.Enqueue(req);
}
@@ -207,7 +207,7 @@ namespace OpenSim.Framework.Servers.HttpServer
if (responsedata == null)
continue;
if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Normal) // This is the event queue
if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) // This is the event queue
{
try
{

View File

@@ -1791,10 +1791,12 @@ namespace OpenSim.Framework
FireAndForget(callback, null);
}
public static void InitThreadPool(int maxThreads)
public static void InitThreadPool(int minThreads, int maxThreads)
{
if (maxThreads < 2)
throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2");
if (minThreads > maxThreads || minThreads < 2)
throw new ArgumentOutOfRangeException("minThreads", "minThreads must be greater than 2 and less than or equal to maxThreads");
if (m_ThreadPool != null)
throw new InvalidOperationException("SmartThreadPool is already initialized");
@@ -1802,7 +1804,7 @@ namespace OpenSim.Framework
startInfo.ThreadPoolName = "Util";
startInfo.IdleTimeout = 2000;
startInfo.MaxWorkerThreads = maxThreads;
startInfo.MinWorkerThreads = 2;
startInfo.MinWorkerThreads = minThreads;
m_ThreadPool = new SmartThreadPool(startInfo);
}
@@ -1877,7 +1879,7 @@ namespace OpenSim.Framework
break;
case FireAndForgetMethod.SmartThreadPool:
if (m_ThreadPool == null)
InitThreadPool(15);
InitThreadPool(2, 15);
m_ThreadPool.QueueWorkItem((cb, o) => cb(o), realCallback, obj);
break;
case FireAndForgetMethod.Thread:
@@ -2265,7 +2267,7 @@ namespace OpenSim.Framework
{
lock (m_syncRoot)
{
m_lowQueue.Enqueue(data);
q.Enqueue(data);
m_s.WaitOne(0);
m_s.Release();
}
@@ -2305,7 +2307,7 @@ namespace OpenSim.Framework
{
if (m_highQueue.Count > 0)
res = m_highQueue.Dequeue();
else
else if (m_lowQueue.Count > 0)
res = m_lowQueue.Dequeue();
if (m_highQueue.Count == 0 && m_lowQueue.Count == 0)