From 99ac770abbe3a95887c4b10c82f3985aa878eeef Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 1 Jun 2014 17:39:11 +0300 Subject: Close streams immediately when we finish using them --- OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/DataSnapshot') diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 4a06f6e..33899aa 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs @@ -373,24 +373,27 @@ namespace OpenSim.Region.DataSnapshot for (int i = 0; i < services.Length; i++) { string url = services[i].Trim(); - RestClient cli = new RestClient(url); - cli.AddQueryParameter("service", serviceName); - cli.AddQueryParameter("host", m_hostname); - cli.AddQueryParameter("port", m_listener_port); - cli.AddQueryParameter("secret", m_Secret.ToString()); - cli.RequestMethod = "GET"; - try - { - reply = cli.Request(null); - } - catch (WebException) + using (RestClient cli = new RestClient(url)) { - m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url); - } - catch (Exception e) - { - m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); + cli.AddQueryParameter("service", serviceName); + cli.AddQueryParameter("host", m_hostname); + cli.AddQueryParameter("port", m_listener_port); + cli.AddQueryParameter("secret", m_Secret.ToString()); + cli.RequestMethod = "GET"; + try + { + reply = cli.Request(null); + } + catch (WebException) + { + m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url); + } + catch (Exception e) + { + m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); + } } + byte[] response = new byte[1024]; // int n = 0; try -- cgit v1.1