aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
diff options
context:
space:
mode:
authorUbitUmarov2013-06-08 19:19:51 +0100
committerUbitUmarov2013-06-08 19:19:51 +0100
commit925a8d47eb18b98e97da9c9e34456914ab0c8d78 (patch)
tree7661cd0fb33c61457a9a8158e664580ca65e6a3f /OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
parentadd indexes for new visual parameters shape_hover and (diff)
parentMerge branch 'avination-current' of ssh://3dhosting.de/var/git/careminster in... (diff)
downloadopensim-SC-925a8d47eb18b98e97da9c9e34456914ab0c8d78.zip
opensim-SC-925a8d47eb18b98e97da9c9e34456914ab0c8d78.tar.gz
opensim-SC-925a8d47eb18b98e97da9c9e34456914ab0c8d78.tar.bz2
opensim-SC-925a8d47eb18b98e97da9c9e34456914ab0c8d78.tar.xz
Merge branch 'avination-current' into ubitwork
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs144
1 files changed, 0 insertions, 144 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 7628e23..5406f00 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -34,143 +34,6 @@ using HttpServer;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Monitoring; 35using OpenSim.Framework.Monitoring;
36using Amib.Threading; 36using Amib.Threading;
37
38
39/*
40namespace OpenSim.Framework.Servers.HttpServer
41{
42
43 public class PollServiceRequestManager
44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 private readonly BaseHttpServer m_server;
48 private static Queue m_requests = Queue.Synchronized(new Queue());
49 private static ManualResetEvent m_ev = new ManualResetEvent(false);
50 private uint m_WorkerThreadCount = 0;
51 private Thread[] m_workerThreads;
52 private PollServiceWorkerThread[] m_PollServiceWorkerThreads;
53 private volatile bool m_running = true;
54 private int m_pollTimeout;
55
56 public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
57 {
58 m_server = pSrv;
59 m_WorkerThreadCount = pWorkerThreadCount;
60 m_pollTimeout = pTimeout;
61 }
62
63 public void Start()
64 {
65 m_running = true;
66 m_workerThreads = new Thread[m_WorkerThreadCount];
67 m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount];
68
69 //startup worker threads
70 for (uint i = 0; i < m_WorkerThreadCount; i++)
71 {
72 m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, m_pollTimeout);
73 m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent;
74
75 m_workerThreads[i]
76 = Watchdog.StartThread(
77 m_PollServiceWorkerThreads[i].ThreadStart,
78 String.Format("PollServiceWorkerThread{0}", i),
79 ThreadPriority.Normal,
80 false,
81 true,
82 int.MaxValue);
83 }
84
85 Watchdog.StartThread(
86 this.ThreadStart,
87 "PollServiceWatcherThread",
88 ThreadPriority.Normal,
89 false,
90 true,
91 1000 * 60 * 10);
92 }
93
94 internal void ReQueueEvent(PollServiceHttpRequest req)
95 {
96 // Do accounting stuff here
97 Enqueue(req);
98 }
99
100 public void Enqueue(PollServiceHttpRequest req)
101 {
102 lock (m_requests)
103 m_requests.Enqueue(req);
104 m_ev.Set();
105 }
106
107 public void ThreadStart()
108 {
109 while (m_running)
110 {
111 m_ev.WaitOne(1000);
112 m_ev.Reset();
113 Watchdog.UpdateThread();
114 ProcessQueuedRequests();
115 }
116 }
117
118 private void ProcessQueuedRequests()
119 {
120 lock (m_requests)
121 {
122 if (m_requests.Count == 0)
123 return;
124
125// m_log.DebugFormat("[POLL SERVICE REQUEST MANAGER]: Processing {0} requests", m_requests.Count);
126
127 int reqperthread = (int) (m_requests.Count/m_WorkerThreadCount) + 1;
128
129 // For Each WorkerThread
130 for (int tc = 0; tc < m_WorkerThreadCount && m_requests.Count > 0; tc++)
131 {
132 //Loop over number of requests each thread handles.
133 for (int i = 0; i < reqperthread && m_requests.Count > 0; i++)
134 {
135 try
136 {
137 m_PollServiceWorkerThreads[tc].Enqueue((PollServiceHttpRequest)m_requests.Dequeue());
138 }
139 catch (InvalidOperationException)
140 {
141 // The queue is empty, we did our calculations wrong!
142 return;
143 }
144
145 }
146 }
147 }
148
149 }
150
151 public void Stop()
152 {
153 m_running = false;
154
155 foreach (object o in m_requests)
156 {
157 PollServiceHttpRequest req = (PollServiceHttpRequest) o;
158 m_server.DoHTTPGruntWork(
159 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id),
160 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
161 }
162
163 m_requests.Clear();
164
165 foreach (Thread t in m_workerThreads)
166 {
167 t.Abort();
168 }
169 }
170 }
171}
172 */
173
174using System.IO; 37using System.IO;
175using System.Text; 38using System.Text;
176using System.Collections.Generic; 39using System.Collections.Generic;
@@ -196,8 +59,6 @@ namespace OpenSim.Framework.Servers.HttpServer
196 59
197 private SmartThreadPool m_threadPool = new SmartThreadPool(20000, 12, 2); 60 private SmartThreadPool m_threadPool = new SmartThreadPool(20000, 12, 2);
198 61
199// private int m_timeout = 1000; // increase timeout 250; now use the event one
200
201 public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout) 62 public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
202 { 63 {
203 m_server = pSrv; 64 m_server = pSrv;
@@ -282,7 +143,6 @@ namespace OpenSim.Framework.Servers.HttpServer
282 ~PollServiceRequestManager() 143 ~PollServiceRequestManager()
283 { 144 {
284 m_running = false; 145 m_running = false;
285// m_timeout = -10000; // cause all to expire
286 Thread.Sleep(1000); // let the world move 146 Thread.Sleep(1000); // let the world move
287 147
288 foreach (Thread t in m_workerThreads) 148 foreach (Thread t in m_workerThreads)
@@ -418,14 +278,10 @@ namespace OpenSim.Framework.Servers.HttpServer
418 } 278 }
419 finally 279 finally
420 { 280 {
421 //response.OutputStream.Close();
422 try 281 try
423 { 282 {
424 response.OutputStream.Flush(); 283 response.OutputStream.Flush();
425 response.Send(); 284 response.Send();
426
427 //if (!response.KeepAlive && response.ReuseContext)
428 // response.FreeContext();
429 } 285 }
430 catch (Exception e) 286 catch (Exception e)
431 { 287 {