diff options
author | Teravus Ovares | 2009-07-30 18:16:00 +0000 |
---|---|---|
committer | Teravus Ovares | 2009-07-30 18:16:00 +0000 |
commit | 23a8895d293f33e8dfcc4aaf56c6fcb49106e979 (patch) | |
tree | 93a1384385a114b8286a4be173d2dde423c457f1 /OpenSim | |
parent | Thank you, dmiles, for a patch that allows more differentiated script (diff) | |
download | opensim-SC-23a8895d293f33e8dfcc4aaf56c6fcb49106e979.zip opensim-SC-23a8895d293f33e8dfcc4aaf56c6fcb49106e979.tar.gz opensim-SC-23a8895d293f33e8dfcc4aaf56c6fcb49106e979.tar.bz2 opensim-SC-23a8895d293f33e8dfcc4aaf56c6fcb49106e979.tar.xz |
* Fixed another potential httpserver leak.
Diffstat (limited to 'OpenSim')
4 files changed, 30 insertions, 3 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index d268457..fbd7166 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -1321,6 +1321,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1321 | string responseString = (string)responsedata["str_response_string"]; | 1321 | string responseString = (string)responsedata["str_response_string"]; |
1322 | string contentType = (string)responsedata["content_type"]; | 1322 | string contentType = (string)responsedata["content_type"]; |
1323 | 1323 | ||
1324 | |||
1324 | if (responsedata.ContainsKey("error_status_text")) | 1325 | if (responsedata.ContainsKey("error_status_text")) |
1325 | { | 1326 | { |
1326 | response.StatusDescription = (string)responsedata["error_status_text"]; | 1327 | response.StatusDescription = (string)responsedata["error_status_text"]; |
@@ -1336,6 +1337,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1336 | response.KeepAlive = keepalive; | 1337 | response.KeepAlive = keepalive; |
1337 | 1338 | ||
1338 | } | 1339 | } |
1340 | |||
1341 | if (responsedata.ContainsKey("reusecontext")) | ||
1342 | response.ReuseContext = (bool) responsedata["reusecontext"]; | ||
1343 | |||
1339 | //Even though only one other part of the entire code uses HTTPHandlers, we shouldn't expect this | 1344 | //Even though only one other part of the entire code uses HTTPHandlers, we shouldn't expect this |
1340 | //and should check for NullReferenceExceptions | 1345 | //and should check for NullReferenceExceptions |
1341 | 1346 | ||
@@ -1391,7 +1396,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1391 | response.OutputStream.Flush(); | 1396 | response.OutputStream.Flush(); |
1392 | response.Send(); | 1397 | response.Send(); |
1393 | 1398 | ||
1394 | if (!response.KeepAlive) | 1399 | if (!response.KeepAlive && response.ReuseContext) |
1395 | response.FreeContext(); | 1400 | response.FreeContext(); |
1396 | } | 1401 | } |
1397 | catch (SocketException e) | 1402 | catch (SocketException e) |
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs index 6c90a92..7029289 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs | |||
@@ -256,6 +256,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | public bool ReuseContext | ||
260 | { | ||
261 | get | ||
262 | { | ||
263 | if (_httpClientContext != null) | ||
264 | { | ||
265 | return !_httpClientContext.EndWhenDone; | ||
266 | } | ||
267 | return true; | ||
268 | } | ||
269 | set | ||
270 | { | ||
271 | if (_httpClientContext != null) | ||
272 | { | ||
273 | _httpClientContext.EndWhenDone = !value; | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | |||
259 | 278 | ||
260 | protected IHttpResponse _httpResponse; | 279 | protected IHttpResponse _httpResponse; |
261 | private IHttpClientContext _httpClientContext; | 280 | private IHttpClientContext _httpClientContext; |
diff --git a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs index a6a90dc..e62407a 100644 --- a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs +++ b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs | |||
@@ -68,6 +68,7 @@ namespace OpenSim.Framework.Servers.Tests | |||
68 | public void Send(byte[] buffer, int offset, int size) {} | 68 | public void Send(byte[] buffer, int offset, int size) {} |
69 | public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {} | 69 | public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {} |
70 | public void Close() { } | 70 | public void Close() { } |
71 | public bool EndWhenDone { get { return false;} set { return;}} | ||
71 | 72 | ||
72 | public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { }; | 73 | public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { }; |
73 | /// <summary> | 74 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs index c064df1..3f0570e 100644 --- a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs | |||
@@ -375,7 +375,8 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
375 | Hashtable responsedata = new Hashtable(); | 375 | Hashtable responsedata = new Hashtable(); |
376 | responsedata["int_response_code"] = 200; | 376 | responsedata["int_response_code"] = 200; |
377 | responsedata["content_type"] = "application/xml"; | 377 | responsedata["content_type"] = "application/xml"; |
378 | responsedata["keepalive"] = true; | 378 | responsedata["keepalive"] = false; |
379 | responsedata["reusecontext"] = false; | ||
379 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); | 380 | responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); |
380 | return responsedata; | 381 | return responsedata; |
381 | //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); | 382 | //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); |
@@ -386,7 +387,8 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue | |||
386 | Hashtable responsedata = new Hashtable(); | 387 | Hashtable responsedata = new Hashtable(); |
387 | responsedata["int_response_code"] = 502; | 388 | responsedata["int_response_code"] = 502; |
388 | responsedata["content_type"] = "text/plain"; | 389 | responsedata["content_type"] = "text/plain"; |
389 | responsedata["keepalive"] = true; | 390 | responsedata["keepalive"] = false; |
391 | responsedata["reusecontext"] = false; | ||
390 | responsedata["str_response_string"] = "Upstream error: "; | 392 | responsedata["str_response_string"] = "Upstream error: "; |
391 | responsedata["error_status_text"] = "Upstream error:"; | 393 | responsedata["error_status_text"] = "Upstream error:"; |
392 | responsedata["http_protocol_version"] = "HTTP/1.0"; | 394 | responsedata["http_protocol_version"] = "HTTP/1.0"; |