Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class TestConnectionCommand : PSCmdlet, IDisposable

#region Private Fields

private static byte[]? s_DefaultSendBuffer;
private static readonly byte[] s_DefaultSendBuffer = Array.Empty<byte>();

private readonly CancellationTokenSource _dnsLookupCancel = new();

Expand Down Expand Up @@ -484,7 +484,10 @@ private void ProcessTraceroute(string targetNameOrAddress)
reply.Status == IPStatus.Success
? reply.RoundtripTime
: timer.ElapsedMilliseconds,
buffer.Length,

// If we use the empty buffer, then .NET actually uses a 32 byte buffer so we want to show
// as the result object the actual buffer size used instead of 0.
buffer.Length == 0 ? DefaultSendBufferSize : buffer.Length,
pingNum: i);
WriteObject(new TraceStatus(
currentHop,
Expand Down Expand Up @@ -707,7 +710,7 @@ private void ProcessPing(string targetNameOrAddress)
resolvedTargetName,
reply,
reply.RoundtripTime,
buffer.Length,
buffer.Length == 0 ? DefaultSendBufferSize : buffer.Length,
pingNum: (uint)i));
}

Expand Down Expand Up @@ -862,7 +865,7 @@ private IPHostEntry GetCancellableHostEntry(string targetNameOrAddress)
// Creates and fills a send buffer. This follows the ping.exe and CoreFX model.
private static byte[] GetSendBuffer(int bufferSize)
{
if (bufferSize == DefaultSendBufferSize && s_DefaultSendBuffer != null)
if (bufferSize == DefaultSendBufferSize)
{
return s_DefaultSendBuffer;
}
Expand All @@ -874,11 +877,6 @@ private static byte[] GetSendBuffer(int bufferSize)
sendBuffer[i] = (byte)((int)'a' + i % 23);
}

if (bufferSize == DefaultSendBufferSize && s_DefaultSendBuffer == null)
{
s_DefaultSendBuffer = sendBuffer;
}

return sendBuffer;
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.