Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStano Peťko <stano@stanopetko.eu>2017-10-30 17:13:16 +0300
committerStephen Toub <stoub@microsoft.com>2017-10-30 17:13:16 +0300
commited3874a12ff4852c9621be20614f98b9eddefaed (patch)
treeb22be131a139ef48fa80109c6179fdf1fcfbd49a /src
parent1cce3631a78c11271f34762253b3a3273a8207fc (diff)
Remove dead code from System.Net.Sockets (#24904)
* Deleted dead code from System.Net.Sockets. * Deleted stuff related to socket perf counters.
Diffstat (limited to 'src')
-rw-r--r--src/System.Net.Sockets/src/System.Net.Sockets.csproj1
-rw-r--r--src/System.Net.Sockets/src/System/Net/SocketPerfCounters.cs33
-rw-r--r--src/System.Net.Sockets/src/System/Net/Sockets/MultipleConnectAsync.cs14
-rw-r--r--src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs323
-rw-r--r--src/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs49
5 files changed, 98 insertions, 322 deletions
diff --git a/src/System.Net.Sockets/src/System.Net.Sockets.csproj b/src/System.Net.Sockets/src/System.Net.Sockets.csproj
index 4883cb0ac4..192143d368 100644
--- a/src/System.Net.Sockets/src/System.Net.Sockets.csproj
+++ b/src/System.Net.Sockets/src/System.Net.Sockets.csproj
@@ -30,7 +30,6 @@
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<!-- CoreCLR (All Operating Systems), .NET Native -->
<Compile Include="System\Net\Sockets\SocketTaskExtensions.cs" />
- <Compile Include="System\Net\SocketPerfCounters.cs" />
<Compile Include="System\Net\Sockets\IOControlCode.cs" />
<Compile Include="System\Net\Sockets\IPPacketInformation.cs" />
<Compile Include="System\Net\Sockets\IPProtectionLevel.cs" />
diff --git a/src/System.Net.Sockets/src/System/Net/SocketPerfCounters.cs b/src/System.Net.Sockets/src/System/Net/SocketPerfCounters.cs
deleted file mode 100644
index 49f4d3531a..0000000000
--- a/src/System.Net.Sockets/src/System/Net/SocketPerfCounters.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Diagnostics;
-using System.Threading;
-
-namespace System.Net
-{
- internal enum SocketPerfCounterName
- {
- SocketConnectionsEstablished = 0, // these enum values are used as index
- SocketBytesReceived,
- SocketBytesSent,
- SocketDatagramsReceived,
- SocketDatagramsSent,
- }
-
- internal sealed class SocketPerfCounter
- {
- private static SocketPerfCounter s_instance;
-
- public static SocketPerfCounter Instance => LazyInitializer.EnsureInitialized(ref s_instance);
-
- public bool Enabled => false; // TODO (#7833): Implement socket perf counters.
-
- [Conditional("TODO7833")]
- public void Increment(SocketPerfCounterName perfCounter, long amount = 1)
- {
- // TODO (#7833): Implement socket perf counters.
- }
- }
-}
diff --git a/src/System.Net.Sockets/src/System/Net/Sockets/MultipleConnectAsync.cs b/src/System.Net.Sockets/src/System/Net/Sockets/MultipleConnectAsync.cs
index 29080a0376..b9f3db19fe 100644
--- a/src/System.Net.Sockets/src/System/Net/Sockets/MultipleConnectAsync.cs
+++ b/src/System.Net.Sockets/src/System/Net/Sockets/MultipleConnectAsync.cs
@@ -33,8 +33,6 @@ namespace System.Net.Sockets
private object _lockObject = new object();
- protected abstract Socket UserSocket { get; }
-
// Called by Socket to kick off the ConnectAsync process. We'll complete the user's SAEA
// when it's done. Returns true if the operation will be asynchronous, false if it has failed synchronously
public bool StartConnectAsync(SocketAsyncEventArgs args, DnsEndPoint endPoint)
@@ -163,7 +161,7 @@ namespace System.Net.Sockets
if (_state == State.Canceled)
{
// If Cancel was called before we got the lock, the Socket will be closed soon. We need to report
- // OperationAborted (even though the connection actually completed), or the user will try to use a
+ // OperationAborted (even though the connection actually completed), or the user will try to use a
// closed Socket.
exception = new SocketException((int)SocketError.OperationAborted);
}
@@ -186,7 +184,7 @@ namespace System.Net.Sockets
}
else
{
-
+
// Keep track of this because it will be overwritten by AttemptConnection
SocketError currentFailure = args.SocketError;
Exception connectException = AttemptConnection();
@@ -270,7 +268,7 @@ namespace System.Net.Sockets
}
catch (ObjectDisposedException)
{
- // This can happen if the user closes the socket, and is equivalent to a call
+ // This can happen if the user closes the socket, and is equivalent to a call
// to CancelConnectAsync
return new SocketException((int)SocketError.OperationAborted);
}
@@ -413,8 +411,6 @@ namespace System.Net.Sockets
private Socket _socket;
private bool _userSocket;
- protected override Socket UserSocket => _socket;
-
public SingleSocketMultipleConnectAsync(Socket socket, bool userSocket)
{
_socket = socket;
@@ -445,7 +441,7 @@ namespace System.Net.Sockets
protected override void OnFail(bool abortive)
{
- // Close the socket if this is an abortive failure (CancelConnectAsync)
+ // Close the socket if this is an abortive failure (CancelConnectAsync)
// or if we created it internally
if (abortive || !_userSocket)
{
@@ -464,8 +460,6 @@ namespace System.Net.Sockets
private Socket _socket4;
private Socket _socket6;
- protected override Socket UserSocket => null;
-
public DualSocketMultipleConnectAsync(SocketType socketType, ProtocolType protocolType)
{
if (Socket.OSSupportsIPv4)
diff --git a/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs b/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
index b7edd69b9b..b6bf2b3131 100644
--- a/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
+++ b/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
@@ -69,7 +69,6 @@ namespace System.Net.Sockets
private int _intCleanedUp; // 0 if not completed, > 0 otherwise.
internal static volatile bool s_initialized;
- internal static readonly bool s_perfCountersEnabled = false; // TODO (#7833): Implement socket perf counters.
#region Constructors
public Socket(SocketType socketType, ProtocolType protocolType)
@@ -334,7 +333,7 @@ namespace System.Net.Sockets
set
{
//
- // This implementation does not support non-IOCP-based async I/O on Windows, and this concept is
+ // This implementation does not support non-IOCP-based async I/O on Windows, and this concept is
// not even meaningful on other platforms. This option is really only functionally meaningful
// if the user calls DuplicateAndClose. Since we also don't support DuplicateAndClose,
// we can safely ignore the caller's choice here, rather than breaking compat further with something
@@ -1148,18 +1147,6 @@ namespace System.Net.Sockets
return 0;
}
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesSent, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsSent);
- }
- }
- }
-
if (NetEventSource.IsEnabled) NetEventSource.Exit(this, bytesTransferred);
return bytesTransferred;
}
@@ -1219,18 +1206,6 @@ namespace System.Net.Sockets
return 0;
}
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesSent, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsSent);
- }
- }
- }
-
if (NetEventSource.IsEnabled)
{
NetEventSource.Info(this, $"Interop.Winsock.send returns:{bytesTransferred}");
@@ -1314,7 +1289,7 @@ namespace System.Net.Sockets
public int SendTo(byte[] buffer, int offset, int size, SocketFlags socketFlags, EndPoint remoteEP)
{
if (NetEventSource.IsEnabled) NetEventSource.Enter(this);
-
+
if (CleanedUp)
{
throw new ObjectDisposedException(this.GetType().FullName);
@@ -1358,18 +1333,6 @@ namespace System.Net.Sockets
_rightEndPoint = endPointSnapshot;
}
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesSent, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsSent);
- }
- }
- }
-
if (NetEventSource.IsEnabled)
{
NetEventSource.DumpBuffer(this, buffer, offset, size);
@@ -1462,20 +1425,6 @@ namespace System.Net.Sockets
return 0;
}
- if (s_perfCountersEnabled)
- {
- bool peek = ((int)socketFlags & (int)SocketFlags.Peek) != 0;
-
- if (bytesTransferred > 0 && !peek)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesReceived, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsReceived);
- }
- }
- }
-
if (NetEventSource.IsEnabled)
{
#if TRACE_VERBOSE
@@ -1587,20 +1536,6 @@ namespace System.Net.Sockets
return 0;
}
- if (s_perfCountersEnabled)
- {
- bool peek = ((int)socketFlags & (int)SocketFlags.Peek) != 0;
-
- if (bytesTransferred > 0 && !peek)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesReceived, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsReceived);
- }
- }
- }
-
#if TRACE_VERBOSE
if (NetEventSource.IsEnabled)
{
@@ -1782,18 +1717,6 @@ namespace System.Net.Sockets
throw socketException;
}
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesReceived, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsReceived);
- }
- }
- }
-
if (NetEventSource.IsEnabled)
{
NetEventSource.DumpBuffer(this, buffer, offset, size);
@@ -1828,7 +1751,7 @@ namespace System.Net.Sockets
int realOptionLength = 0;
// IOControl is used for Windows-specific IOCTL operations. If we need to add support for IOCTLs specific
- // to other platforms, we will likely need to add a new API, as the control codes may overlap with those
+ // to other platforms, we will likely need to add a new API, as the control codes may overlap with those
// from Windows. Generally it would be preferable to add new methods/properties to abstract these across
// platforms, however.
SocketError errorCode = SocketPal.WindowsIoctl(_handle, ioControlCode, optionInValue, optionOutValue, out realOptionLength);
@@ -1973,7 +1896,7 @@ namespace System.Net.Sockets
out optionValue);
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Interop.Winsock.getsockopt returns errorCode:{errorCode}");
-
+
// Throw an appropriate SocketException if the native call fails.
if (errorCode != SocketError.Success)
{
@@ -2119,17 +2042,17 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// BeginConnect - Does an async connect.
- //
+ //
// Arguments:
- //
+ //
// remoteEP - status line that we wish to parse
// Callback - Async Callback Delegate that is called upon Async Completion
// State - State used to track callback, set by caller, not required
- //
+ //
// Return Value:
- //
+ //
// IAsyncResult - Async result used to retrieve result
public IAsyncResult BeginConnect(EndPoint remoteEP, AsyncCallback callback, object state)
{
@@ -2178,7 +2101,7 @@ namespace System.Net.Sockets
{
//
// On Windows, we cannot duplicate a socket that is bound to an IOCP. In this implementation, we *only*
- // support IOCPs, so this will not work.
+ // support IOCPs, so this will not work.
//
// On Unix, duplication of a socket into an arbitrary process is not supported at all.
//
@@ -2409,16 +2332,16 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// EndConnect - Called after receiving callback from BeginConnect,
// in order to retrieve the result of async call
- //
+ //
// Arguments:
- //
+ //
// AsyncResult - the AsyncResult Returned from BeginConnect call
- //
+ //
// Return Value:
- //
+ //
// int - Return code from async Connect, 0 for success, SocketError.NotConnected otherwise
public void EndConnect(IAsyncResult asyncResult)
{
@@ -2544,21 +2467,21 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// BeginSend - Async implementation of Send call, mirrored after BeginReceive
// This routine may go pending at which time,
// but any case the callback Delegate will be called upon completion
- //
+ //
// Arguments:
- //
+ //
// WriteBuffer - status line that we wish to parse
// Index - Offset into WriteBuffer to begin sending from
// Size - Size of Buffer to transmit
// Callback - Delegate function that holds callback, called on completion of I/O
// State - State used to track callback, set by caller, not required
- //
+ //
// Return Value:
- //
+ //
// IAsyncResult - Async result used to retrieve result
public IAsyncResult BeginSend(byte[] buffer, int offset, int size, SocketFlags socketFlags, AsyncCallback callback, object state)
{
@@ -2626,7 +2549,7 @@ namespace System.Net.Sockets
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Interop.Winsock.WSASend returns:{errorCode} size:{size} returning AsyncResult:{asyncResult}");
- // If the call failed, update our status
+ // If the call failed, update our status
CheckErrorAndUpdateStatus(errorCode);
return errorCode;
@@ -2691,23 +2614,23 @@ namespace System.Net.Sockets
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Interop.Winsock.WSASend returns:{errorCode} returning AsyncResult:{asyncResult}");
- // If the call failed, update our status
+ // If the call failed, update our status
CheckErrorAndUpdateStatus(errorCode);
return errorCode;
}
// Routine Description:
- //
+ //
// EndSend - Called by user code after I/O is done or the user wants to wait.
// until Async completion, needed to retrieve error result from call
- //
+ //
// Arguments:
- //
+ //
// AsyncResult - the AsyncResult Returned from BeginSend call
- //
+ //
// Return Value:
- //
+ //
// int - Number of bytes transferred
public int EndSend(IAsyncResult asyncResult)
{
@@ -2747,18 +2670,6 @@ namespace System.Net.Sockets
int bytesTransferred = castedAsyncResult.InternalWaitForCompletionInt32Result();
castedAsyncResult.EndCalled = true;
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesSent, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsSent);
- }
- }
- }
-
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"bytesTransffered:{bytesTransferred}");
// Throw an appropriate SocketException if the native call failed asynchronously.
@@ -2826,14 +2737,14 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// BeginSendTo - Async implementation of SendTo,
- //
+ //
// This routine may go pending at which time,
// but any case the callback Delegate will be called upon completion
- //
+ //
// Arguments:
- //
+ //
// WriteBuffer - Buffer to transmit
// Index - Offset into WriteBuffer to begin sending from
// Size - Size of Buffer to transmit
@@ -2841,9 +2752,9 @@ namespace System.Net.Sockets
// remoteEP - EndPoint to transmit To
// Callback - Delegate function that holds callback, called on completion of I/O
// State - State used to track callback, set by caller, not required
- //
+ //
// Return Value:
- //
+ //
// IAsyncResult - Async result used to retrieve result
public IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, SocketFlags socketFlags, EndPoint remoteEP, AsyncCallback callback, object state)
{
@@ -2927,16 +2838,16 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// EndSendTo - Called by user code after I/O is done or the user wants to wait.
// until Async completion, needed to retrieve error result from call
- //
+ //
// Arguments:
- //
+ //
// AsyncResult - the AsyncResult Returned from BeginSend call
- //
+ //
// Return Value:
- //
+ //
// int - Number of bytes transferred
public int EndSendTo(IAsyncResult asyncResult)
{
@@ -2966,18 +2877,6 @@ namespace System.Net.Sockets
int bytesTransferred = castedAsyncResult.InternalWaitForCompletionInt32Result();
castedAsyncResult.EndCalled = true;
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesSent, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsSent);
- }
- }
- }
-
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"bytesTransferred:{bytesTransferred}");
// Throw an appropriate SocketException if the native call failed asynchronously.
@@ -2991,26 +2890,26 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// BeginReceive - Async implementation of Recv call,
- //
+ //
// Called when we want to start an async receive.
// We kick off the receive, and if it completes synchronously we'll
// call the callback. Otherwise we'll return an IASyncResult, which
// the caller can use to wait on or retrieve the final status, as needed.
- //
+ //
// Uses Winsock 2 overlapped I/O.
- //
+ //
// Arguments:
- //
+ //
// ReadBuffer - status line that we wish to parse
// Index - Offset into ReadBuffer to begin reading from
// Size - Size of Buffer to recv
// Callback - Delegate function that holds callback, called on completion of I/O
// State - State used to track callback, set by caller, not required
- //
+ //
// Return Value:
- //
+ //
// IAsyncResult - Async result used to retrieve result
public IAsyncResult BeginReceive(byte[] buffer, int offset, int size, SocketFlags socketFlags, AsyncCallback callback, object state)
{
@@ -3152,7 +3051,7 @@ namespace System.Net.Sockets
SocketError errorCode = SocketPal.ReceiveAsync(_handle, buffers, socketFlags, asyncResult);
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Interop.Winsock.WSARecv returns:{errorCode} returning AsyncResult:{asyncResult}");
-
+
if (!CheckErrorAndUpdateStatus(errorCode))
{
}
@@ -3175,17 +3074,17 @@ namespace System.Net.Sockets
#endif
// Routine Description:
- //
+ //
// EndReceive - Called when I/O is done or the user wants to wait. If
// the I/O isn't done, we'll wait for it to complete, and then we'll return
// the bytes of I/O done.
- //
+ //
// Arguments:
- //
+ //
// AsyncResult - the AsyncResult Returned from BeginSend call
- //
+ //
// Return Value:
- //
+ //
// int - Number of bytes transferred
public int EndReceive(IAsyncResult asyncResult)
{
@@ -3226,18 +3125,6 @@ namespace System.Net.Sockets
int bytesTransferred = castedAsyncResult.InternalWaitForCompletionInt32Result();
castedAsyncResult.EndCalled = true;
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesReceived, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsReceived);
- }
- }
- }
-
#if TRACE_VERBOSE
if (NetEventSource.IsEnabled)
{
@@ -3436,18 +3323,6 @@ namespace System.Net.Sockets
}
}
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesReceived, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsReceived);
- }
- }
- }
-
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"bytesTransferred:{bytesTransferred}");
// Throw an appropriate SocketException if the native call failed asynchronously.
@@ -3464,18 +3339,18 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// BeginReceiveFrom - Async implementation of RecvFrom call,
- //
+ //
// Called when we want to start an async receive.
// We kick off the receive, and if it completes synchronously we'll
// call the callback. Otherwise we'll return an IASyncResult, which
// the caller can use to wait on or retrieve the final status, as needed.
- //
+ //
// Uses Winsock 2 overlapped I/O.
- //
+ //
// Arguments:
- //
+ //
// ReadBuffer - status line that we wish to parse
// Index - Offset into ReadBuffer to begin reading from
// Request - Size of Buffer to recv
@@ -3483,9 +3358,9 @@ namespace System.Net.Sockets
// remoteEP - EndPoint that are to receive from
// Callback - Delegate function that holds callback, called on completion of I/O
// State - State used to track callback, set by caller, not required
- //
+ //
// Return Value:
- //
+ //
// IAsyncResult - Async result used to retrieve result
public IAsyncResult BeginReceiveFrom(byte[] buffer, int offset, int size, SocketFlags socketFlags, ref EndPoint remoteEP, AsyncCallback callback, object state)
{
@@ -3596,17 +3471,17 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// EndReceiveFrom - Called when I/O is done or the user wants to wait. If
// the I/O isn't done, we'll wait for it to complete, and then we'll return
// the bytes of I/O done.
- //
+ //
// Arguments:
- //
+ //
// AsyncResult - the AsyncResult Returned from BeginReceiveFrom call
- //
+ //
// Return Value:
- //
+ //
// int - Number of bytes transferred
public int EndReceiveFrom(IAsyncResult asyncResult, ref EndPoint endPoint)
{
@@ -3660,18 +3535,6 @@ namespace System.Net.Sockets
}
}
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesReceived, bytesTransferred);
- if (Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsReceived);
- }
- }
- }
-
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"bytesTransferred:{bytesTransferred}");
// Throw an appropriate SocketException if the native call failed asynchronously.
@@ -3684,22 +3547,22 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// BeginAccept - Does an async winsock accept, creating a new socket on success
- //
+ //
// Works by creating a pending accept request the first time,
// and subsequent calls are queued so that when the first accept completes,
// the next accept can be resubmitted in the callback.
// this routine may go pending at which time,
// but any case the callback Delegate will be called upon completion
- //
+ //
// Arguments:
- //
+ //
// Callback - Async Callback Delegate that is called upon Async Completion
// State - State used to track callback, set by caller, not required
- //
+ //
// Return Value:
- //
+ //
// IAsyncResult - Async result used to retrieve resultant new socket
public IAsyncResult BeginAccept(AsyncCallback callback, object state)
{
@@ -3778,17 +3641,17 @@ namespace System.Net.Sockets
}
// Routine Description:
- //
+ //
// EndAccept - Called by user code after I/O is done or the user wants to wait.
// until Async completion, so it provides End handling for async Accept calls,
// and retrieves new Socket object
- //
+ //
// Arguments:
- //
+ //
// AsyncResult - the AsyncResult Returned from BeginAccept call
- //
+ //
// Return Value:
- //
+ //
// Socket - a valid socket if successful
public Socket EndAccept(IAsyncResult asyncResult)
{
@@ -3837,14 +3700,6 @@ namespace System.Net.Sockets
castedAsyncResult.EndCalled = true;
- if (s_perfCountersEnabled)
- {
- if (bytesTransferred > 0)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesReceived, bytesTransferred);
- }
- }
-
// Throw an appropriate SocketException if the native call failed asynchronously.
if ((SocketError)castedAsyncResult.ErrorCode != SocketError.Success)
{
@@ -4025,7 +3880,7 @@ namespace System.Net.Sockets
}
}
- // Save the old RightEndPoint and prep new RightEndPoint.
+ // Save the old RightEndPoint and prep new RightEndPoint.
EndPoint oldEndPoint = _rightEndPoint;
if (_rightEndPoint == null)
{
@@ -4046,7 +3901,7 @@ namespace System.Net.Sockets
{
_rightEndPoint = oldEndPoint;
- // Clear in-use flag on event args object.
+ // Clear in-use flag on event args object.
e.Complete();
throw;
}
@@ -4085,7 +3940,7 @@ namespace System.Net.Sockets
MultipleConnectAsync multipleConnectAsync = null;
if (dnsEP.AddressFamily == AddressFamily.Unspecified)
{
- // This is the only *Connect* API that fully supports multiple endpoint attempts, as it's responsible
+ // This is the only *Connect* API that fully supports multiple endpoint attempts, as it's responsible
// for creating each Socket instance and can create one per attempt.
multipleConnectAsync = new DualSocketMultipleConnectAsync(socketType, protocolType);
#pragma warning restore
@@ -4141,7 +3996,7 @@ namespace System.Net.Sockets
}
catch
{
- // clear in-use on event arg object
+ // clear in-use on event arg object
e.Complete();
throw;
}
@@ -4180,7 +4035,7 @@ namespace System.Net.Sockets
}
catch
{
- // Clear in-use flag on event args object.
+ // Clear in-use flag on event args object.
e.Complete();
throw;
}
@@ -4220,7 +4075,7 @@ namespace System.Net.Sockets
EndPoint endPointSnapshot = e.RemoteEndPoint;
e._socketAddress = SnapshotAndSerialize(ref endPointSnapshot);
- // DualMode sockets may have updated the endPointSnapshot, and it has to have the same AddressFamily as
+ // DualMode sockets may have updated the endPointSnapshot, and it has to have the same AddressFamily as
// e.m_SocketAddres for Create to work later.
e.RemoteEndPoint = endPointSnapshot;
@@ -4238,7 +4093,7 @@ namespace System.Net.Sockets
}
catch
{
- // Clear in-use flag on event args object.
+ // Clear in-use flag on event args object.
e.Complete();
throw;
}
@@ -4278,7 +4133,7 @@ namespace System.Net.Sockets
EndPoint endPointSnapshot = e.RemoteEndPoint;
e._socketAddress = SnapshotAndSerialize(ref endPointSnapshot);
- // DualMode may have updated the endPointSnapshot, and it has to have the same AddressFamily as
+ // DualMode may have updated the endPointSnapshot, and it has to have the same AddressFamily as
// e.m_SocketAddres for Create to work later.
e.RemoteEndPoint = endPointSnapshot;
@@ -4297,7 +4152,7 @@ namespace System.Net.Sockets
}
catch
{
- // Clear in-use flag on event args object.
+ // Clear in-use flag on event args object.
e.Complete();
throw;
}
@@ -4335,7 +4190,7 @@ namespace System.Net.Sockets
}
catch
{
- // Clear in-use flag on event args object.
+ // Clear in-use flag on event args object.
e.Complete();
throw;
}
@@ -4385,7 +4240,7 @@ namespace System.Net.Sockets
}
catch (Exception)
{
- // Clear in-use flag on event args object.
+ // Clear in-use flag on event args object.
e.Complete();
throw;
}
@@ -4438,7 +4293,7 @@ namespace System.Net.Sockets
}
catch
{
- // Clear in-use flag on event args object.
+ // Clear in-use flag on event args object.
e.Complete();
throw;
}
@@ -5090,7 +4945,7 @@ namespace System.Net.Sockets
{
private EndPoint _endPoint;
- internal ConnectAsyncResult(object myObject, EndPoint endPoint, object myState, AsyncCallback myCallBack) :
+ internal ConnectAsyncResult(object myObject, EndPoint endPoint, object myState, AsyncCallback myCallBack) :
base(myObject, myState, myCallBack)
{
_endPoint = endPoint;
@@ -5296,10 +5151,6 @@ namespace System.Net.Sockets
_isConnected = true;
_isDisconnected = false;
if (NetEventSource.IsEnabled) NetEventSource.Info(this, "now connected");
- if (s_perfCountersEnabled)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketConnectionsEstablished);
- }
}
internal void SetToDisconnected()
diff --git a/src/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs b/src/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs
index 5b5eb8c38d..9f0eabd5a5 100644
--- a/src/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs
+++ b/src/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs
@@ -131,7 +131,7 @@ namespace System.Net.Sockets
}
// NOTE: this property is mutually exclusive with Buffer.
- // Setting this property with an existing non-null Buffer will throw.
+ // Setting this property with an existing non-null Buffer will throw.
public IList<ArraySegment<byte>> BufferList
{
get { return _bufferList; }
@@ -172,7 +172,7 @@ namespace System.Net.Sockets
{
_bufferListInternal?.Clear();
}
-
+
_bufferList = value;
SetupMultipleBuffers();
@@ -329,7 +329,7 @@ namespace System.Net.Sockets
throw new ArgumentException(SR.Format(SR.net_ambiguousbuffers, nameof(BufferList)));
}
- // Offset and count can't be negative and the
+ // Offset and count can't be negative and the
// combination must be in bounds of the array.
if (offset < 0 || offset > buffer.Length)
{
@@ -393,14 +393,14 @@ namespace System.Net.Sockets
}
// Marks this object as no longer "in-use". Will also execute a Dispose deferred
- // because I/O was in progress.
+ // because I/O was in progress.
internal void Complete()
{
// Mark as not in-use.
_operating = Free;
// Check for deferred Dispose().
- // The deferred Dispose is not guaranteed if Dispose is called while an operation is in progress.
+ // The deferred Dispose is not guaranteed if Dispose is called while an operation is in progress.
// The _disposeCalled variable is not managed in a thread-safe manner on purpose for performance.
if (_disposeCalled)
{
@@ -499,7 +499,7 @@ namespace System.Net.Sockets
// If our caller specified a buffer (willing to get received data with the Accept) then
// it needs to be large enough for the two special sockaddr buffers that AcceptEx requires.
- // Throw if that buffer is not large enough.
+ // Throw if that buffer is not large enough.
bool userSuppliedBuffer = _buffer != null;
if (userSuppliedBuffer)
{
@@ -612,26 +612,6 @@ namespace System.Net.Sockets
InnerStartOperationSendTo();
}
- internal void UpdatePerfCounters(int size, bool sendOp)
- {
- if (sendOp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesSent, size);
- if (_currentSocket.Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsSent);
- }
- }
- else
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketBytesReceived, size);
- if (_currentSocket.Transport == TransportType.Udp)
- {
- SocketPerfCounter.Instance.Increment(SocketPerfCounterName.SocketDatagramsReceived);
- }
- }
- }
-
internal void FinishOperationSyncFailure(SocketError socketError, int bytesTransferred, SocketFlags flags)
{
SetResults(socketError, bytesTransferred, flags);
@@ -710,7 +690,7 @@ namespace System.Net.Sockets
{
SetResults(SocketError.Success, bytesTransferred, flags);
- if (NetEventSource.IsEnabled || Socket.s_perfCountersEnabled)
+ if (NetEventSource.IsEnabled)
{
LogBytesTransferred(bytesTransferred, _completedOperation);
}
@@ -810,21 +790,6 @@ namespace System.Net.Sockets
{
LogBuffer(bytesTransferred);
}
-
- if (Socket.s_perfCountersEnabled)
- {
- bool sendOp = false;
- switch (operation)
- {
- case SocketAsyncOperation.Connect:
- case SocketAsyncOperation.Send:
- case SocketAsyncOperation.SendPackets:
- case SocketAsyncOperation.SendTo:
- sendOp = true;
- break;
- }
- UpdatePerfCounters(bytesTransferred, sendOp);
- }
}
}