From 62771560448edbc2112d427acd4b37780dfe2154 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 14 May 2009 20:37:54 +0000 Subject: * When saving an oar, save assets when immediately received rather than storing them all up in memory * Hopefully this will remove out of memory problems when saving large oars on machines without much memory * It may also speed up saving of large oars --- .../Framework/Serialization/TarArchiveWriter.cs | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'OpenSim/Framework/Serialization') diff --git a/OpenSim/Framework/Serialization/TarArchiveWriter.cs b/OpenSim/Framework/Serialization/TarArchiveWriter.cs index d319b0b..316a8de 100644 --- a/OpenSim/Framework/Serialization/TarArchiveWriter.cs +++ b/OpenSim/Framework/Serialization/TarArchiveWriter.cs @@ -109,10 +109,14 @@ namespace OpenSim.Framework.Serialization // Write two consecutive 0 blocks to end the archive byte[] finalZeroPadding = new byte[1024]; - m_bw.Write(finalZeroPadding); - m_bw.Flush(); - m_bw.Close(); + lock (m_bw) + { + m_bw.Write(finalZeroPadding); + + m_bw.Flush(); + m_bw.Close(); + } } public static byte[] ConvertDecimalToPaddedOctalBytes(int d, int padding) @@ -197,20 +201,23 @@ namespace OpenSim.Framework.Serialization header[154] = 0; - // Write out header - m_bw.Write(header); - - // Write out data - m_bw.Write(data); - - if (data.Length % 512 != 0) + lock (m_bw) { - int paddingRequired = 512 - (data.Length % 512); - - //m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired); - - byte[] padding = new byte[paddingRequired]; - m_bw.Write(padding); + // Write out header + m_bw.Write(header); + + // Write out data + m_bw.Write(data); + + if (data.Length % 512 != 0) + { + int paddingRequired = 512 - (data.Length % 512); + + //m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired); + + byte[] padding = new byte[paddingRequired]; + m_bw.Write(padding); + } } } } -- cgit v1.1