diff options
author | Justin Clark-Casey (justincc) | 2011-10-25 20:24:21 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-10-25 20:24:21 +0100 |
commit | 8a0a78cbccce796addacab7ed1609279b802a9b3 (patch) | |
tree | 31ddb6da7bca6eeb61cb7747532dcf77828cfbe3 /OpenSim/Framework/Servers/HttpServer | |
parent | Drop some unnecessary ContainsKey() checking before Remove() in BaseHttpServer() (diff) | |
download | opensim-SC_OLD-8a0a78cbccce796addacab7ed1609279b802a9b3.zip opensim-SC_OLD-8a0a78cbccce796addacab7ed1609279b802a9b3.tar.gz opensim-SC_OLD-8a0a78cbccce796addacab7ed1609279b802a9b3.tar.bz2 opensim-SC_OLD-8a0a78cbccce796addacab7ed1609279b802a9b3.tar.xz |
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)
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer')
3 files changed, 25 insertions, 19 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index 65b1eb5..fd77984 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs | |||
@@ -49,7 +49,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Add a handler for an HTTP request. | 50 | /// Add a handler for an HTTP request. |
51 | /// </summary> | 51 | /// </summary> |
52 | /// | 52 | /// <remarks> |
53 | /// This handler can actually be invoked either as | 53 | /// This handler can actually be invoked either as |
54 | /// | 54 | /// |
55 | /// http://<hostname>:<port>/?method=<methodName> | 55 | /// http://<hostname>:<port>/?method=<methodName> |
@@ -70,7 +70,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
70 | /// In addition, the handler invoked by the HTTP server for any request is the one when best matches the request | 70 | /// In addition, the handler invoked by the HTTP server for any request is the one when best matches the request |
71 | /// URI. So if a handler for "/myapp/" is registered and a request for "/myapp/page" is received, then | 71 | /// URI. So if a handler for "/myapp/" is registered and a request for "/myapp/page" is received, then |
72 | /// the "/myapp/" handler is invoked if no "/myapp/page" handler exists. | 72 | /// the "/myapp/" handler is invoked if no "/myapp/page" handler exists. |
73 | /// | 73 | /// </remarks> |
74 | /// <param name="methodName"></param> | 74 | /// <param name="methodName"></param> |
75 | /// <param name="handler"></param> | 75 | /// <param name="handler"></param> |
76 | /// <returns> | 76 | /// <returns> |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 0840a9d..ea30b9a 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -31,6 +31,7 @@ using System.Threading; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using HttpServer; | 33 | using HttpServer; |
34 | using OpenSim.Framework; | ||
34 | 35 | ||
35 | namespace OpenSim.Framework.Servers.HttpServer | 36 | namespace OpenSim.Framework.Servers.HttpServer |
36 | { | 37 | { |
@@ -54,21 +55,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
54 | m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount]; | 55 | m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount]; |
55 | 56 | ||
56 | //startup worker threads | 57 | //startup worker threads |
57 | for (uint i=0;i<m_WorkerThreadCount;i++) | 58 | for (uint i = 0; i < m_WorkerThreadCount; i++) |
58 | { | 59 | { |
59 | m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, pTimeout); | 60 | m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, pTimeout); |
60 | m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent; | 61 | m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent; |
61 | 62 | ||
62 | m_workerThreads[i] = new Thread(m_PollServiceWorkerThreads[i].ThreadStart); | 63 | // m_workerThreads[i] |
63 | m_workerThreads[i].Name = String.Format("PollServiceWorkerThread{0}",i); | 64 | // = Watchdog.StartThread( |
64 | //Can't add to thread Tracker here Referencing OpenSim.Framework creates circular reference | 65 | // m_PollServiceWorkerThreads[i].ThreadStart, |
65 | m_workerThreads[i].Start(); | 66 | // String.Format("PollServiceWorkerThread{0}", i), |
67 | // ThreadPriority.Normal, | ||
68 | // false); | ||
66 | } | 69 | } |
67 | 70 | ||
68 | //start watcher threads | 71 | m_watcherThread |
69 | m_watcherThread = new Thread(ThreadStart); | 72 | = Watchdog.StartThread( |
70 | m_watcherThread.Name = "PollServiceWatcherThread"; | 73 | this.ThreadStart, |
71 | m_watcherThread.Start(); | 74 | "PollServiceWatcherThread", |
75 | ThreadPriority.Normal, | ||
76 | false); | ||
72 | } | 77 | } |
73 | 78 | ||
74 | internal void ReQueueEvent(PollServiceHttpRequest req) | 79 | internal void ReQueueEvent(PollServiceHttpRequest req) |
@@ -83,10 +88,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
83 | m_requests.Enqueue(req); | 88 | m_requests.Enqueue(req); |
84 | } | 89 | } |
85 | 90 | ||
86 | public void ThreadStart(object o) | 91 | public void ThreadStart() |
87 | { | 92 | { |
88 | while (m_running) | 93 | while (m_running) |
89 | { | 94 | { |
95 | Watchdog.UpdateThread(); | ||
90 | ProcessQueuedRequests(); | 96 | ProcessQueuedRequests(); |
91 | Thread.Sleep(1000); | 97 | Thread.Sleep(1000); |
92 | } | 98 | } |
@@ -107,7 +113,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
107 | for (int tc = 0; tc < m_WorkerThreadCount && m_requests.Count > 0; tc++) | 113 | for (int tc = 0; tc < m_WorkerThreadCount && m_requests.Count > 0; tc++) |
108 | { | 114 | { |
109 | //Loop over number of requests each thread handles. | 115 | //Loop over number of requests each thread handles. |
110 | for (int i=0;i<reqperthread && m_requests.Count > 0;i++) | 116 | for (int i = 0; i < reqperthread && m_requests.Count > 0; i++) |
111 | { | 117 | { |
112 | try | 118 | try |
113 | { | 119 | { |
@@ -125,14 +131,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
125 | 131 | ||
126 | } | 132 | } |
127 | 133 | ||
128 | |||
129 | |||
130 | ~PollServiceRequestManager() | 134 | ~PollServiceRequestManager() |
131 | { | 135 | { |
132 | foreach (object o in m_requests) | 136 | foreach (object o in m_requests) |
133 | { | 137 | { |
134 | PollServiceHttpRequest req = (PollServiceHttpRequest) o; | 138 | PollServiceHttpRequest req = (PollServiceHttpRequest) o; |
135 | m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); | 139 | m_server.DoHTTPGruntWork( |
140 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), | ||
141 | new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); | ||
136 | } | 142 | } |
137 | 143 | ||
138 | m_requests.Clear(); | 144 | m_requests.Clear(); |
@@ -144,4 +150,4 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
144 | m_running = false; | 150 | m_running = false; |
145 | } | 151 | } |
146 | } | 152 | } |
147 | } | 153 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs index b91496b..16e56d2 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
59 | m_timeout = pTimeout; | 59 | m_timeout = pTimeout; |
60 | } | 60 | } |
61 | 61 | ||
62 | public void ThreadStart(object o) | 62 | public void ThreadStart() |
63 | { | 63 | { |
64 | Run(); | 64 | Run(); |
65 | } | 65 | } |