diff options
author | Oren Hurvitz | 2014-06-01 17:39:11 +0300 |
---|---|---|
committer | Oren Hurvitz | 2014-07-21 08:30:03 +0100 |
commit | 99ac770abbe3a95887c4b10c82f3985aa878eeef (patch) | |
tree | 8c946dab083dd50a352f3861415eca43185d8d95 /OpenSim/Region/CoreModules/World/Serialiser | |
parent | Set "[Terrain]SendTerrainUpdatesByViewDistance=true" by default. (diff) | |
download | opensim-SC-99ac770abbe3a95887c4b10c82f3985aa878eeef.zip opensim-SC-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.gz opensim-SC-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.bz2 opensim-SC-99ac770abbe3a95887c4b10c82f3985aa878eeef.tar.xz |
Close streams immediately when we finish using them
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Serialiser')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs b/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs index 328fbf0..65f464a 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs | |||
@@ -54,13 +54,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser | |||
54 | { | 54 | { |
55 | string xmlstream = GetObjectXml(scene); | 55 | string xmlstream = GetObjectXml(scene); |
56 | 56 | ||
57 | MemoryStream stream = ReformatXmlString(xmlstream); | 57 | using (MemoryStream stream = ReformatXmlString(xmlstream)) |
58 | 58 | { | |
59 | stream.Seek(0, SeekOrigin.Begin); | 59 | stream.Seek(0, SeekOrigin.Begin); |
60 | CreateXmlFile(stream, fileName); | 60 | CreateXmlFile(stream, fileName); |
61 | 61 | ||
62 | stream.Seek(0, SeekOrigin.Begin); | 62 | stream.Seek(0, SeekOrigin.Begin); |
63 | CreateCompressedXmlFile(stream, fileName); | 63 | CreateCompressedXmlFile(stream, fileName); |
64 | } | ||
64 | } | 65 | } |
65 | 66 | ||
66 | private static MemoryStream ReformatXmlString(string xmlstream) | 67 | private static MemoryStream ReformatXmlString(string xmlstream) |
@@ -112,13 +113,16 @@ namespace OpenSim.Region.CoreModules.World.Serialiser | |||
112 | { | 113 | { |
113 | #region GZip Compressed Version | 114 | #region GZip Compressed Version |
114 | 115 | ||
115 | FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); | 116 | using (FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create)) |
116 | MemoryStream gzipMSStream = new MemoryStream(); | 117 | using (MemoryStream gzipMSStream = new MemoryStream()) |
117 | GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); | 118 | { |
118 | xmlStream.WriteTo(gzipStream); | 119 | using (GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress, true)) |
119 | gzipMSStream.WriteTo(objectsFileCompressed); | 120 | { |
120 | objectsFileCompressed.Flush(); | 121 | xmlStream.WriteTo(gzipStream); |
121 | objectsFileCompressed.Close(); | 122 | } |
123 | |||
124 | gzipMSStream.WriteTo(objectsFileCompressed); | ||
125 | } | ||
122 | 126 | ||
123 | #endregion | 127 | #endregion |
124 | } | 128 | } |