diff options
author | Dr Scofield | 2008-06-25 13:10:12 +0000 |
---|---|---|
committer | Dr Scofield | 2008-06-25 13:10:12 +0000 |
commit | daca971bf6de2020be00c6f0641494bd481bd091 (patch) | |
tree | 463c4f1f00907c6d83217b99397a0e1db763bb69 /OpenSim/Framework/Servers/OSHttpServer.cs | |
parent | taking another look at mantis #1502: adding necessary locks, checking for emp... (diff) | |
download | opensim-SC_OLD-daca971bf6de2020be00c6f0641494bd481bd091.zip opensim-SC_OLD-daca971bf6de2020be00c6f0641494bd481bd091.tar.gz opensim-SC_OLD-daca971bf6de2020be00c6f0641494bd481bd091.tar.bz2 opensim-SC_OLD-daca971bf6de2020be00c6f0641494bd481bd091.tar.xz |
further work on the HttpServer stuff. not functional yet. just sharing
what crimes i'm committing.
Diffstat (limited to 'OpenSim/Framework/Servers/OSHttpServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/OSHttpServer.cs | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/OpenSim/Framework/Servers/OSHttpServer.cs b/OpenSim/Framework/Servers/OSHttpServer.cs index 3aa8042..296f853 100644 --- a/OpenSim/Framework/Servers/OSHttpServer.cs +++ b/OpenSim/Framework/Servers/OSHttpServer.cs | |||
@@ -50,8 +50,12 @@ namespace OpenSim.Framework.Servers | |||
50 | 50 | ||
51 | // underlying HttpServer.HttpListener | 51 | // underlying HttpServer.HttpListener |
52 | protected HttpListener _listener; | 52 | protected HttpListener _listener; |
53 | // underlying core/engine thread | ||
53 | protected Thread _engine; | 54 | protected Thread _engine; |
54 | 55 | ||
56 | // Queue containing (OS)HttpRequests | ||
57 | protected OSHttpRequestQueue _queue; | ||
58 | |||
55 | // OSHttpRequestPumps "pumping" incoming OSHttpRequests | 59 | // OSHttpRequestPumps "pumping" incoming OSHttpRequests |
56 | // upwards | 60 | // upwards |
57 | protected OSHttpRequestPump[] _pumps; | 61 | protected OSHttpRequestPump[] _pumps; |
@@ -72,6 +76,11 @@ namespace OpenSim.Framework.Servers | |||
72 | get { return _isSecure; } | 76 | get { return _isSecure; } |
73 | } | 77 | } |
74 | 78 | ||
79 | public int QueueSize | ||
80 | { | ||
81 | get { return _pumps.Length; } | ||
82 | } | ||
83 | |||
75 | /// <summary> | 84 | /// <summary> |
76 | /// Instantiate an HTTP server. | 85 | /// Instantiate an HTTP server. |
77 | /// </summary> | 86 | /// </summary> |
@@ -80,17 +89,37 @@ namespace OpenSim.Framework.Servers | |||
80 | _engineId = String.Format("OSHttpServer [HTTP:{0}/ps:{1}]", port, poolSize); | 89 | _engineId = String.Format("OSHttpServer [HTTP:{0}/ps:{1}]", port, poolSize); |
81 | _isSecure = false; | 90 | _isSecure = false; |
82 | 91 | ||
83 | _pumps = OSHttpRequestPump.Pumps(this, poolSize); | 92 | _listener = new HttpListener(address, port); |
93 | _queue = new OSHttpRequestQueue(); | ||
94 | _pumps = OSHttpRequestPump.Pumps(this, _queue, poolSize); | ||
84 | } | 95 | } |
85 | 96 | ||
86 | /// <summary> | 97 | /// <summary> |
87 | /// Instantiate an HTTPS server. | 98 | /// Instantiate an HTTPS server. |
88 | /// </summary> | 99 | /// </summary> |
89 | public OSHttpServer(IPAddress address, int port, X509Certificate certificate, int poolSize) : | 100 | public OSHttpServer(IPAddress address, int port, X509Certificate certificate, int poolSize) |
90 | this(address, port, poolSize) | ||
91 | { | 101 | { |
92 | _engineId = String.Format("OSHttpServer [HTTPS:{0}/ps:{1}]", port, poolSize); | 102 | _engineId = String.Format("OSHttpServer [HTTPS:{0}/ps:{1}]", port, poolSize); |
93 | _isSecure = true; | 103 | _isSecure = true; |
104 | |||
105 | _listener = new HttpListener(address, port, certificate); | ||
106 | _queue = new OSHttpRequestQueue(); | ||
107 | _pumps = OSHttpRequestPump.Pumps(this, _queue, poolSize); | ||
108 | } | ||
109 | |||
110 | /// <summary> | ||
111 | /// Turn an HttpRequest into an OSHttpRequestItem and place it | ||
112 | /// in the queue. The OSHttpRequestQueue object will pulse the | ||
113 | /// next available idle pump. | ||
114 | /// </summary> | ||
115 | protected void OnHttpRequest(HttpClientContext client, HttpRequest request) | ||
116 | { | ||
117 | // turn request into OSHttpRequest | ||
118 | OSHttpRequest req = new OSHttpRequest(client, request); | ||
119 | |||
120 | // place OSHttpRequest into _httpRequestQueue, will | ||
121 | // trigger Pulse to idle waiting pumps | ||
122 | _queue.Enqueue(req); | ||
94 | } | 123 | } |
95 | 124 | ||
96 | /// <summary> | 125 | /// <summary> |
@@ -102,6 +131,7 @@ namespace OpenSim.Framework.Servers | |||
102 | _engine.Name = _engineId; | 131 | _engine.Name = _engineId; |
103 | _engine.IsBackground = true; | 132 | _engine.IsBackground = true; |
104 | _engine.Start(); | 133 | _engine.Start(); |
134 | |||
105 | ThreadTracker.Add(_engine); | 135 | ThreadTracker.Add(_engine); |
106 | } | 136 | } |
107 | 137 | ||
@@ -111,9 +141,12 @@ namespace OpenSim.Framework.Servers | |||
111 | { | 141 | { |
112 | while (true) | 142 | while (true) |
113 | { | 143 | { |
114 | // do stuff | 144 | _listener.RequestHandler += OnHttpRequest; |
145 | _listener.Start(QueueSize); | ||
115 | } | 146 | } |
116 | } | 147 | } |
117 | 148 | ||
149 | |||
150 | |||
118 | } | 151 | } |
119 | } | 152 | } |