do not trust ms documentation about inner stream dispose

master
UbitUmarov 2020-06-29 01:03:00 +01:00
parent 16cfb3deab
commit 34fa6abc00
5 changed files with 6 additions and 14 deletions

View File

@ -285,14 +285,13 @@ namespace OpenSim.Framework
if (tickdiff > LongCallTime) if (tickdiff > LongCallTime)
{ {
m_log.InfoFormat( m_log.InfoFormat(
"[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {7} bytes ({8} uncomp): {9}", "[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4} bytes ({5} uncomp): {6}",
reqnum, reqnum,
method, method,
url, url,
tickdiff, tickdiff,
compsize, compsize,
strBuffer != null ? strBuffer.Length : 0, strBuffer != null ? strBuffer.Length : 0,
strBuffer != null strBuffer != null
? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer)
: ""); : "");
@ -795,19 +794,16 @@ namespace OpenSim.Framework
request.Method = verb; request.Method = verb;
MemoryStream buffer = null;
byte[] data = null; byte[] data = null;
try try
{ {
if (verb == "POST") if (verb == "POST")
{ {
request.ContentType = "text/xml"; request.ContentType = "text/xml";
buffer = new MemoryStream();
XmlWriterSettings settings = new XmlWriterSettings(); XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8; settings.Encoding = Encoding.UTF8;
using (MemoryStream buffer = new MemoryStream())
using (XmlWriter writer = XmlWriter.Create(buffer, settings)) using (XmlWriter writer = XmlWriter.Create(buffer, settings))
{ {
XmlSerializer serializer = new XmlSerializer(type); XmlSerializer serializer = new XmlSerializer(type);
@ -948,11 +944,7 @@ namespace OpenSim.Framework
reqnum, tickdiff, tickdata); reqnum, tickdiff, tickdata);
} }
} }
finally catch { }
{
if (buffer != null && buffer.CanRead)
buffer.Dispose();
}
} }
} }
@ -1277,8 +1269,8 @@ namespace OpenSim.Framework
request.ContentType = "text/xml"; request.ContentType = "text/xml";
byte[] data; byte[] data;
XmlWriterSettings settings = new XmlWriterSettings(){CloseOutput = true, Encoding = Util.UTF8}; XmlWriterSettings settings = new XmlWriterSettings(){Encoding = Util.UTF8};
MemoryStream ms = new MemoryStream(); using (MemoryStream ms = new MemoryStream())
using (XmlWriter writer = XmlWriter.Create(ms, settings)) using (XmlWriter writer = XmlWriter.Create(ms, settings))
{ {
XmlSerializer serializer = new XmlSerializer(type); XmlSerializer serializer = new XmlSerializer(type);

Binary file not shown.

Binary file not shown.

Binary file not shown.