From e41e52e09727842d990a31e2a5f7f3e9c88fe8b3 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 --- .../CoreModules/World/Archiver/ArchiveReadRequest.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index e9c6fb6..c8056d4 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -918,17 +918,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver { ITerrainModule terrainModule = scene.RequestModuleInterface(); - MemoryStream ms = new MemoryStream(data); - if (m_displacement != Vector3.Zero || m_rotation != 0f) + using (MemoryStream ms = new MemoryStream(data)) { - Vector2 rotationCenter = new Vector2(m_rotationCenter.X, m_rotationCenter.Y); - terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, rotationCenter, ms); - } - else - { - terrainModule.LoadFromStream(terrainPath, ms); + if (m_displacement != Vector3.Zero || m_rotation != 0f) + { + Vector2 rotationCenter = new Vector2(m_rotationCenter.X, m_rotationCenter.Y); + terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, rotationCenter, ms); + } + else + { + terrainModule.LoadFromStream(terrainPath, ms); + } } - ms.Close(); m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath); -- cgit v1.1