Skip to content

Commit 7c5689a

Browse files
committed
Specify the 'tag' when getting a stream.
This could be useful if we use an ETW event monitor such as PerfView to collect and analyze ETW events because many of these events contain helpful clues about the stream in question, including its tag, guid, and stacks (if enabled).
1 parent 05fc748 commit 7c5689a

3 files changed

Lines changed: 6 additions & 9 deletions

File tree

Source/HttpMultipartParser/BinaryStreamStack.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,7 @@ public void Push(byte[] data)
142142
/// </param>
143143
public void Push(byte[] data, int offset, int count)
144144
{
145-
var stream = Utilities.MemoryStreamManager.GetStream();
146-
stream.Write(data, offset, count);
147-
stream.Position = 0;
148-
145+
var stream = Utilities.MemoryStreamManager.GetStream($"{typeof(BinaryStreamStack).FullName}.{nameof(Push)}", data, offset, count);
149146
streams.Push(new BinaryReader(stream, CurrentEncoding));
150147
}
151148

@@ -306,7 +303,7 @@ public byte[] ReadByteLine(out bool hitStreamEnd)
306303
byte[] ignore = CurrentEncoding.GetBytes(new[] { '\r' });
307304
byte[] search = CurrentEncoding.GetBytes(new[] { '\n' });
308305
int searchPos = 0;
309-
using (var builder = Utilities.MemoryStreamManager.GetStream())
306+
using (var builder = Utilities.MemoryStreamManager.GetStream($"{typeof(BinaryStreamStack).FullName}.{nameof(ReadByteLine)}"))
310307
{
311308
while (true)
312309
{

Source/HttpMultipartParser/MultipartFormDataParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ private void ParseStream(Stream stream, string boundary, Encoding encoding, int
562562
if (partNumber == 0)
563563
{
564564
// create file with first partNo
565-
Files.Add(new FilePart(name, fileName, Utilities.MemoryStreamManager.GetStream(), type, disposition));
565+
Files.Add(new FilePart(name, fileName, Utilities.MemoryStreamManager.GetStream($"{typeof(MultipartFormDataParser).FullName}.{nameof(ParseStream)}"), type, disposition));
566566
}
567567

568568
Files[Files.Count - 1].Data.Write(buffer, 0, bytes);
@@ -607,7 +607,7 @@ private async Task ParseStreamAsync(Stream stream, string boundary, Encoding enc
607607
if (partNumber == 0)
608608
{
609609
// create file with first partNo
610-
Files.Add(new FilePart(name, fileName, Utilities.MemoryStreamManager.GetStream(), type, disposition));
610+
Files.Add(new FilePart(name, fileName, Utilities.MemoryStreamManager.GetStream($"{typeof(MultipartFormDataParser).FullName}.{nameof(ParseStreamAsync)}"), type, disposition));
611611
}
612612

613613
Files[Files.Count - 1].Data.Write(buffer, 0, bytes);

Source/HttpMultipartParser/RebufferableBinaryReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public int Read(char[] buffer, int index, int count)
265265
/// </returns>
266266
public byte[] ReadByteLine()
267267
{
268-
using (var builder = Utilities.MemoryStreamManager.GetStream())
268+
using (var builder = Utilities.MemoryStreamManager.GetStream($"{typeof(RebufferableBinaryReader).FullName}.{nameof(ReadByteLine)}"))
269269
{
270270
while (true)
271271
{
@@ -424,7 +424,7 @@ public async Task<int> ReadAsync(char[] buffer, int index, int count, Cancellati
424424
/// </returns>
425425
public async Task<byte[]> ReadByteLineAsync(CancellationToken cancellationToken = default)
426426
{
427-
using (var builder = Utilities.MemoryStreamManager.GetStream())
427+
using (var builder = Utilities.MemoryStreamManager.GetStream($"{typeof(RebufferableBinaryReader).FullName}.{nameof(ReadByteLineAsync)}"))
428428
{
429429
while (true)
430430
{

0 commit comments

Comments
 (0)