mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
+7
-9
@@ -56,7 +56,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static byte[]? s_DefaultSendBuffer;
|
||||
private static readonly byte[] s_DefaultSendBuffer = Array.Empty<byte>();
|
||||
|
||||
private readonly CancellationTokenSource _dnsLookupCancel = new();
|
||||
|
||||
@@ -484,7 +484,10 @@ namespace Microsoft.PowerShell.Commands
|
||||
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,
|
||||
@@ -707,7 +710,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
resolvedTargetName,
|
||||
reply,
|
||||
reply.RoundtripTime,
|
||||
buffer.Length,
|
||||
buffer.Length == 0 ? DefaultSendBufferSize : buffer.Length,
|
||||
pingNum: (uint)i));
|
||||
}
|
||||
|
||||
@@ -862,7 +865,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
// 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;
|
||||
}
|
||||
@@ -874,11 +877,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
sendBuffer[i] = (byte)((int)'a' + i % 23);
|
||||
}
|
||||
|
||||
if (bufferSize == DefaultSendBufferSize && s_DefaultSendBuffer == null)
|
||||
{
|
||||
s_DefaultSendBuffer = sendBuffer;
|
||||
}
|
||||
|
||||
return sendBuffer;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user