simplify PollServiceRequestManager, now that low level does serielaze requests

master
UbitUmarov 2020-05-02 15:25:05 +01:00
parent 6d030e2f2b
commit 0b0b5111df
1 changed files with 2 additions and 68 deletions

View File

@ -41,7 +41,6 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<int, Queue<PollServiceHttpRequest>> m_bycontext;
private BlockingCollection<PollServiceHttpRequest> m_requests = new BlockingCollection<PollServiceHttpRequest>(); private BlockingCollection<PollServiceHttpRequest> m_requests = new BlockingCollection<PollServiceHttpRequest>();
private ConcurrentQueue<PollServiceHttpRequest> m_retryRequests = new ConcurrentQueue<PollServiceHttpRequest>(); private ConcurrentQueue<PollServiceHttpRequest> m_retryRequests = new ConcurrentQueue<PollServiceHttpRequest>();
@ -59,7 +58,6 @@ namespace OpenSim.Framework.Servers.HttpServer
m_WorkerThreadCount = pWorkerThreadCount; m_WorkerThreadCount = pWorkerThreadCount;
m_workerThreads = new Thread[m_WorkerThreadCount]; m_workerThreads = new Thread[m_WorkerThreadCount];
m_bycontext = new Dictionary<int, Queue<PollServiceHttpRequest>>(256);
/* /*
STPStartInfo startInfo = new STPStartInfo(); STPStartInfo startInfo = new STPStartInfo();
startInfo.IdleTimeout = 30000; startInfo.IdleTimeout = 30000;
@ -110,60 +108,6 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
public void Enqueue(PollServiceHttpRequest req) public void Enqueue(PollServiceHttpRequest req)
{
Queue<PollServiceHttpRequest> ctxQeueue;
int rhash = req.contextHash;
lock (m_bycontext)
{
if (m_bycontext.TryGetValue(rhash, out ctxQeueue))
{
ctxQeueue.Enqueue(req);
}
else
{
ctxQeueue = new Queue<PollServiceHttpRequest>();
m_bycontext[rhash] = ctxQeueue;
EnqueueInt(req);
}
}
}
public void byContextDequeue(PollServiceHttpRequest req)
{
Queue<PollServiceHttpRequest> ctxQeueue;
int rhash = req.contextHash;
lock (m_bycontext)
{
if (m_bycontext.TryGetValue(rhash, out ctxQeueue))
{
if (ctxQeueue.Count > 0)
{
PollServiceHttpRequest newreq = ctxQeueue.Dequeue();
EnqueueInt(newreq);
}
else
{
m_bycontext.Remove(rhash);
}
}
}
}
public void DropByContext(PollServiceHttpRequest req)
{
Queue<PollServiceHttpRequest> ctxQeueue;
int rhash = req.contextHash;
lock (m_bycontext)
{
if (m_bycontext.TryGetValue(rhash, out ctxQeueue))
{
ctxQeueue.Clear();
m_bycontext.Remove(rhash);
}
}
}
public void EnqueueInt(PollServiceHttpRequest req)
{ {
if(m_running) if(m_running)
m_requests.Add(req); m_requests.Add(req);
@ -197,10 +141,6 @@ namespace OpenSim.Framework.Servers.HttpServer
// any entry in m_bycontext should have a active request on the other queues // any entry in m_bycontext should have a active request on the other queues
// so just delete contents to easy GC // so just delete contents to easy GC
foreach (Queue<PollServiceHttpRequest> qu in m_bycontext.Values)
qu.Clear();
m_bycontext.Clear();
PollServiceHttpRequest req; PollServiceHttpRequest req;
try try
{ {
@ -219,9 +159,7 @@ namespace OpenSim.Framework.Servers.HttpServer
catch catch
{ {
} }
m_requests.Dispose(); m_requests.Dispose();
} }
// work threads // work threads
@ -245,7 +183,6 @@ namespace OpenSim.Framework.Servers.HttpServer
if (!req.HttpContext.CanSend()) if (!req.HttpContext.CanSend())
{ {
req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id);
byContextDequeue(req);
continue; continue;
} }
@ -254,7 +191,6 @@ namespace OpenSim.Framework.Servers.HttpServer
if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
{ {
req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id);
byContextDequeue(req);
} }
else else
ReQueueEvent(req); ReQueueEvent(req);
@ -274,7 +210,6 @@ namespace OpenSim.Framework.Servers.HttpServer
catch (ObjectDisposedException) { } catch (ObjectDisposedException) { }
finally finally
{ {
byContextDequeue(nreq);
nreq = null; nreq = null;
} }
//return null; //return null;
@ -294,7 +229,6 @@ namespace OpenSim.Framework.Servers.HttpServer
catch (ObjectDisposedException) { } catch (ObjectDisposedException) { }
finally finally
{ {
byContextDequeue(nreq);
nreq = null; nreq = null;
} }
//return null; //return null;