diff --git a/src/Shared/runtime/NetEventSource.Common.cs b/src/Shared/runtime/NetEventSource.Common.cs index 48a67e115596deb8397b8a9c85a2bdad7eceda67..c7c062c0750e7edb22dca25ba09abe019214eac0 100644 --- a/src/Shared/runtime/NetEventSource.Common.cs +++ b/src/Shared/runtime/NetEventSource.Common.cs @@ -29,14 +29,9 @@ namespace System.Net // Usage: // - Operations that may allocate (e.g. boxing a value type, using string interpolation, etc.) or that may have computations // at call sites should guard access like: - // if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this, refArg1, valueTypeArg2); // entering an instance method with a value type arg // if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(null, $"Found certificate: {cert}"); // info logging with a formattable string // - Operations that have zero allocations / measurable computations at call sites can use a simpler pattern, calling methods like: - // NetEventSource.Enter(this); // entering an instance method // NetEventSource.Info(this, "literal string"); // arbitrary message with a literal string - // NetEventSource.Enter(this, refArg1, regArg2); // entering an instance method with two reference type arguments - // NetEventSource.Enter(null); // entering a static method - // NetEventSource.Enter(null, refArg1); // entering a static method with one reference type argument // Debug.Asserts inside the logging methods will help to flag some misuse if the DEBUG_NETEVENTSOURCE_MISUSE compilation constant is defined. // However, because it can be difficult by observation to understand all of the costs involved, guarding can be done everywhere. // - NetEventSource.Fail calls typically do not need to be prefixed with an IsEnabled check, even if they allocate, as FailMessage @@ -103,7 +98,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(formattableString); - if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); + if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); } /// <summary>Logs entrance to a method.</summary> @@ -115,7 +110,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); - if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)})"); + if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)})"); } /// <summary>Logs entrance to a method.</summary> @@ -129,7 +124,7 @@ namespace System.Net DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); DebugValidateArg(arg1); - if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)})"); + if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)})"); } /// <summary>Logs entrance to a method.</summary> @@ -145,7 +140,7 @@ namespace System.Net DebugValidateArg(arg0); DebugValidateArg(arg1); DebugValidateArg(arg2); - if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)}, {Format(arg2)})"); + if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)}, {Format(arg2)})"); } [Event(EnterEventId, Level = EventLevel.Informational, Keywords = Keywords.EnterExit)] @@ -163,7 +158,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(formattableString); - if (Log.IsEnabled()) Log.Exit(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); + if (IsEnabled) Log.Exit(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); } /// <summary>Logs exit from a method.</summary> @@ -175,7 +170,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); - if (Log.IsEnabled()) Log.Exit(IdOf(thisOrContextObject), memberName, Format(arg0).ToString()); + if (IsEnabled) Log.Exit(IdOf(thisOrContextObject), memberName, Format(arg0).ToString()); } /// <summary>Logs exit from a method.</summary> @@ -189,7 +184,7 @@ namespace System.Net DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); DebugValidateArg(arg1); - if (Log.IsEnabled()) Log.Exit(IdOf(thisOrContextObject), memberName, $"{Format(arg0)}, {Format(arg1)}"); + if (IsEnabled) Log.Exit(IdOf(thisOrContextObject), memberName, $"{Format(arg0)}, {Format(arg1)}"); } [Event(ExitEventId, Level = EventLevel.Informational, Keywords = Keywords.EnterExit)] @@ -207,7 +202,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(formattableString); - if (Log.IsEnabled()) Log.Info(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); + if (IsEnabled) Log.Info(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters); } /// <summary>Logs an information message.</summary> @@ -219,7 +214,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(message); - if (Log.IsEnabled()) Log.Info(IdOf(thisOrContextObject), memberName, Format(message).ToString()); + if (IsEnabled) Log.Info(IdOf(thisOrContextObject), memberName, Format(message).ToString()); } [Event(InfoEventId, Level = EventLevel.Informational, Keywords = Keywords.Default)] @@ -237,7 +232,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(formattableString); - if (Log.IsEnabled()) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(formattableString)); + if (IsEnabled) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(formattableString)); } /// <summary>Logs an error message.</summary> @@ -249,7 +244,7 @@ namespace System.Net { DebugValidateArg(thisOrContextObject); DebugValidateArg(message); - if (Log.IsEnabled()) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(message).ToString()); + if (IsEnabled) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(message).ToString()); } [Event(ErrorEventId, Level = EventLevel.Error, Keywords = Keywords.Default)] @@ -268,7 +263,7 @@ namespace System.Net // Don't call DebugValidateArg on args, as we expect Fail to be used in assert/failure situations // that should never happen in production, and thus we don't care about extra costs. - if (Log.IsEnabled()) Log.CriticalFailure(IdOf(thisOrContextObject), memberName, Format(formattableString)); + if (IsEnabled) Log.CriticalFailure(IdOf(thisOrContextObject), memberName, Format(formattableString)); Debug.Fail(Format(formattableString), $"{IdOf(thisOrContextObject)}.{memberName}"); } @@ -282,7 +277,7 @@ namespace System.Net // Don't call DebugValidateArg on args, as we expect Fail to be used in assert/failure situations // that should never happen in production, and thus we don't care about extra costs. - if (Log.IsEnabled()) Log.CriticalFailure(IdOf(thisOrContextObject), memberName, Format(message).ToString()); + if (IsEnabled) Log.CriticalFailure(IdOf(thisOrContextObject), memberName, Format(message).ToString()); Debug.Fail(Format(message).ToString(), $"{IdOf(thisOrContextObject)}.{memberName}"); } @@ -311,7 +306,7 @@ namespace System.Net [NonEvent] public static void DumpBuffer(object? thisOrContextObject, byte[] buffer, int offset, int count, [CallerMemberName] string? memberName = null) { - if (Log.IsEnabled()) + if (IsEnabled) { if (offset < 0 || offset > buffer.Length - count) { @@ -343,7 +338,7 @@ namespace System.Net Debug.Assert(bufferPtr != IntPtr.Zero); Debug.Assert(count >= 0); - if (Log.IsEnabled()) + if (IsEnabled) { var buffer = new byte[Math.Min(count, MaxDumpSize)]; fixed (byte* targetPtr = buffer) @@ -369,7 +364,7 @@ namespace System.Net { DebugValidateArg(first); DebugValidateArg(second); - if (Log.IsEnabled()) Log.Associate(IdOf(first), memberName, IdOf(first), IdOf(second)); + if (IsEnabled) Log.Associate(IdOf(first), memberName, IdOf(first), IdOf(second)); } /// <summary>Logs a relationship between two objects.</summary> @@ -383,7 +378,7 @@ namespace System.Net DebugValidateArg(thisOrContextObject); DebugValidateArg(first); DebugValidateArg(second); - if (Log.IsEnabled()) Log.Associate(IdOf(thisOrContextObject), memberName, IdOf(first), IdOf(second)); + if (IsEnabled) Log.Associate(IdOf(thisOrContextObject), memberName, IdOf(first), IdOf(second)); } [Event(AssociateEventId, Level = EventLevel.Informational, Keywords = Keywords.Default, Message = "[{2}]<-->[{3}]")] @@ -396,7 +391,7 @@ namespace System.Net [Conditional("DEBUG_NETEVENTSOURCE_MISUSE")] private static void DebugValidateArg(object? arg) { - if (!Log.IsEnabled()) + if (!IsEnabled) { Debug.Assert(!(arg is ValueType), $"Should not be passing value type {arg?.GetType()} to logging without IsEnabled check"); Debug.Assert(!(arg is FormattableString), $"Should not be formatting FormattableString \"{arg}\" if tracing isn't enabled"); @@ -406,9 +401,12 @@ namespace System.Net [Conditional("DEBUG_NETEVENTSOURCE_MISUSE")] private static void DebugValidateArg(FormattableString? arg) { - Debug.Assert(Log.IsEnabled() || arg == null, $"Should not be formatting FormattableString \"{arg}\" if tracing isn't enabled"); + Debug.Assert(IsEnabled || arg == null, $"Should not be formatting FormattableString \"{arg}\" if tracing isn't enabled"); } + public static new bool IsEnabled => + Log.IsEnabled(); + [NonEvent] public static string IdOf(object? value) => value != null ? value.GetType().Name + "#" + GetHashCode(value) : NullInstance; diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicConnection.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicConnection.cs index 4fe328965a0d5e4231a8a77b481f932fbe5a1080..0046c56abb0dea595bf85d379b6482a5d47c770f 100644 --- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicConnection.cs +++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicConnection.cs @@ -51,21 +51,17 @@ namespace System.Net.Quic.Implementations.MsQuic // constructor for inbound connections public MsQuicConnection(IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, IntPtr nativeObjPtr) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); _localEndPoint = localEndPoint; _remoteEndPoint = remoteEndPoint; _ptr = nativeObjPtr; SetCallbackHandler(); SetIdleTimeout(TimeSpan.FromSeconds(120)); - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } // constructor for outbound connections public MsQuicConnection(QuicClientConnectionOptions options) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - // TODO need to figure out if/how we want to expose sessions // Creating a session per connection isn't ideal. _session = new MsQuicSession(); @@ -74,8 +70,6 @@ namespace System.Net.Quic.Implementations.MsQuic SetCallbackHandler(); SetIdleTimeout(options.IdleTimeout); - - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override IPEndPoint LocalEndPoint @@ -168,8 +162,6 @@ namespace System.Net.Quic.Implementations.MsQuic private uint HandleEventConnected(ConnectionEvent connectionEvent) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - SOCKADDR_INET inetAddress = MsQuicParameterHelpers.GetINetParam(MsQuicApi.Api, _ptr, (uint)QUIC_PARAM_LEVEL.CONNECTION, (uint)QUIC_PARAM_CONN.LOCAL_ADDRESS); _localEndPoint = MsQuicAddressHelpers.INetToIPEndPoint(inetAddress); @@ -179,14 +171,11 @@ namespace System.Net.Quic.Implementations.MsQuic // handle event shutdown initiated by transport _connectTcs.Complete(MsQuicStatusCodes.Success); - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleEventShutdownInitiatedByTransport(ConnectionEvent connectionEvent) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - if (!_connected) { _connectTcs.CompleteException(new IOException("Connection has been shutdown.")); @@ -194,7 +183,6 @@ namespace System.Net.Quic.Implementations.MsQuic _acceptQueue.Writer.Complete(); - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } @@ -208,23 +196,14 @@ namespace System.Net.Quic.Implementations.MsQuic private uint HandleEventShutdownComplete(ConnectionEvent connectionEvent) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - _shutdownTcs.Complete(MsQuicStatusCodes.Success); - - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return MsQuicStatusCodes.Success; } private uint HandleEventNewStream(ConnectionEvent connectionEvent) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - MsQuicStream msQuicStream = new MsQuicStream(this, connectionEvent.StreamFlags, connectionEvent.Data.NewStream.Stream, inbound: true); - _acceptQueue.Writer.TryWrite(msQuicStream); - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return MsQuicStatusCodes.Success; } @@ -235,8 +214,6 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask<QuicStreamProvider> AcceptStreamAsync(CancellationToken cancellationToken = default) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - ThrowIfDisposed(); MsQuicStream stream; @@ -254,7 +231,6 @@ namespace System.Net.Quic.Implementations.MsQuic }; } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return stream; } @@ -305,8 +281,6 @@ namespace System.Net.Quic.Implementations.MsQuic private MsQuicStream StreamOpen( QUIC_STREAM_OPEN_FLAG flags) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - IntPtr streamPtr = IntPtr.Zero; QuicExceptionHelpers.ThrowIfFailed( MsQuicApi.Api.StreamOpenDelegate( @@ -317,10 +291,7 @@ namespace System.Net.Quic.Implementations.MsQuic out streamPtr), "Failed to open stream to peer."); - MsQuicStream stream = new MsQuicStream(this, flags, streamPtr, inbound: false); - - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return stream; + return new MsQuicStream(this, flags, streamPtr, inbound: false); } private void SetCallbackHandler() @@ -337,15 +308,12 @@ namespace System.Net.Quic.Implementations.MsQuic QUIC_CONNECTION_SHUTDOWN_FLAG Flags, long ErrorCode) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - uint status = MsQuicApi.Api.ConnectionShutdownDelegate( _ptr, (uint)Flags, ErrorCode); QuicExceptionHelpers.ThrowIfFailed(status, "Failed to shutdown connection."); - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return _shutdownTcs.GetTypelessValueTask(); } @@ -377,8 +345,6 @@ namespace System.Net.Quic.Implementations.MsQuic return; } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - if (_ptr != IntPtr.Zero) { MsQuicApi.Api.ConnectionCloseDelegate?.Invoke(_ptr); @@ -394,8 +360,6 @@ namespace System.Net.Quic.Implementations.MsQuic } _disposed = true; - - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override ValueTask CloseAsync(long errorCode, CancellationToken cancellationToken = default) diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicListener.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicListener.cs index 0a9b004bb6a5f7e88b2817aa6279cf60dc5918e9..c8d338832398cd8bc9c616c6a0cd3cbaa485814a 100644 --- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicListener.cs +++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicListener.cs @@ -62,8 +62,6 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask<QuicConnectionProvider> AcceptConnectionAsync(CancellationToken cancellationToken = default) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - ThrowIfDisposed(); MsQuicConnection connection; @@ -81,7 +79,6 @@ namespace System.Net.Quic.Implementations.MsQuic _options.CertificateFilePath, _options.PrivateKeyFilePath).ConfigureAwait(false); - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return connection; } diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs index 085abfd84ad14828aef35e09fa9610b98581e5e4..6b8e9ce362d9cbb96c015bffeb493a8f3200f827 100644 --- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs +++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs @@ -124,8 +124,6 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask WriteAsync(ReadOnlySequence<byte> buffers, bool endStream, CancellationToken cancellationToken = default) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - ThrowIfDisposed(); using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken).ConfigureAwait(false); @@ -133,8 +131,6 @@ namespace System.Net.Quic.Implementations.MsQuic await SendReadOnlySequenceAsync(buffers, endStream ? QUIC_SEND_FLAG.FIN : QUIC_SEND_FLAG.NONE).ConfigureAwait(false); HandleWriteCompletedState(); - - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override ValueTask WriteAsync(ReadOnlyMemory<ReadOnlyMemory<byte>> buffers, CancellationToken cancellationToken = default) @@ -144,8 +140,6 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask WriteAsync(ReadOnlyMemory<ReadOnlyMemory<byte>> buffers, bool endStream, CancellationToken cancellationToken = default) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - ThrowIfDisposed(); using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken).ConfigureAwait(false); @@ -153,14 +147,10 @@ namespace System.Net.Quic.Implementations.MsQuic await SendReadOnlyMemoryListAsync(buffers, endStream ? QUIC_SEND_FLAG.FIN : QUIC_SEND_FLAG.NONE).ConfigureAwait(false); HandleWriteCompletedState(); - - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, bool endStream, CancellationToken cancellationToken = default) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - ThrowIfDisposed(); using CancellationTokenRegistration registration = await HandleWriteStartState(cancellationToken).ConfigureAwait(false); @@ -168,8 +158,6 @@ namespace System.Net.Quic.Implementations.MsQuic await SendReadOnlyMemoryAsync(buffer, endStream ? QUIC_SEND_FLAG.FIN : QUIC_SEND_FLAG.NONE).ConfigureAwait(false); HandleWriteCompletedState(); - - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } private async ValueTask<CancellationTokenRegistration> HandleWriteStartState(CancellationToken cancellationToken) @@ -228,8 +216,6 @@ namespace System.Net.Quic.Implementations.MsQuic internal override async ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - ThrowIfDisposed(); if (!_canRead) @@ -241,7 +227,6 @@ namespace System.Net.Quic.Implementations.MsQuic { if (_readState == ReadState.ReadsCompleted) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return 0; } else if (_readState == ReadState.Aborted) @@ -310,8 +295,6 @@ namespace System.Net.Quic.Implementations.MsQuic } } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return actual; } @@ -319,8 +302,6 @@ namespace System.Net.Quic.Implementations.MsQuic // If so, we need to complete the read here as well. internal override void AbortRead(long errorCode) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - ThrowIfDisposed(); lock (_sync) @@ -330,13 +311,10 @@ namespace System.Net.Quic.Implementations.MsQuic MsQuicApi.Api.StreamShutdownDelegate(_ptr, (uint)QUIC_STREAM_SHUTDOWN_FLAG.ABORT_RECV, errorCode); - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override void AbortWrite(long errorCode) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - ThrowIfDisposed(); bool shouldComplete = false; @@ -356,14 +334,10 @@ namespace System.Net.Quic.Implementations.MsQuic } MsQuicApi.Api.StreamShutdownDelegate(_ptr, (uint)QUIC_STREAM_SHUTDOWN_FLAG.ABORT_SEND, errorCode); - - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); } internal override ValueTask ShutdownWriteCompleted(CancellationToken cancellationToken = default) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - ThrowIfDisposed(); // TODO do anything to stop writes? @@ -385,8 +359,6 @@ namespace System.Net.Quic.Implementations.MsQuic } }); - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return _shutdownWriteResettableCompletionSource.GetTypelessValueTask(); } @@ -434,8 +406,6 @@ namespace System.Net.Quic.Implementations.MsQuic return default; } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - CleanupSendState(); if (_ptr != IntPtr.Zero) @@ -448,7 +418,6 @@ namespace System.Net.Quic.Implementations.MsQuic _handle.Free(); _disposed = true; - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); return default; } @@ -471,8 +440,6 @@ namespace System.Net.Quic.Implementations.MsQuic return; } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - CleanupSendState(); if (_ptr != IntPtr.Zero) @@ -484,8 +451,6 @@ namespace System.Net.Quic.Implementations.MsQuic _handle.Free(); - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - _disposed = true; } @@ -577,8 +542,6 @@ namespace System.Net.Quic.Implementations.MsQuic private unsafe uint HandleEventRecv(ref MsQuicNativeMethods.StreamEvent evt) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - StreamEventDataRecv receieveEvent = evt.Data.Recv; for (int i = 0; i < receieveEvent.BufferCount; i++) { @@ -600,15 +563,11 @@ namespace System.Net.Quic.Implementations.MsQuic _receiveResettableCompletionSource.Complete((uint)receieveEvent.TotalBufferLength); } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return MsQuicStatusCodes.Pending; } private uint HandleEventPeerRecvAborted(ref StreamEvent evt) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - bool shouldComplete = false; lock (_sync) { @@ -625,15 +584,11 @@ namespace System.Net.Quic.Implementations.MsQuic _sendResettableCompletionSource.CompleteException(new QuicStreamAbortedException(_sendErrorCode)); } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return MsQuicStatusCodes.Success; } private uint HandleStartComplete() { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - bool shouldComplete = false; lock (_sync) { @@ -649,14 +604,11 @@ namespace System.Net.Quic.Implementations.MsQuic _sendResettableCompletionSource.Complete(MsQuicStatusCodes.Success); } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return MsQuicStatusCodes.Success; } private uint HandleEventSendShutdownComplete(ref MsQuicNativeMethods.StreamEvent evt) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); bool shouldComplete = false; lock (_sync) { @@ -672,15 +624,11 @@ namespace System.Net.Quic.Implementations.MsQuic _shutdownWriteResettableCompletionSource.Complete(MsQuicStatusCodes.Success); } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return MsQuicStatusCodes.Success; } private uint HandleEventShutdownComplete() { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - bool shouldReadComplete = false; bool shouldShutdownWriteComplete = false; @@ -713,15 +661,11 @@ namespace System.Net.Quic.Implementations.MsQuic _shutdownWriteResettableCompletionSource.Complete(MsQuicStatusCodes.Success); } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return MsQuicStatusCodes.Success; } private uint HandleEventPeerSendAborted(ref StreamEvent evt) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - bool shouldComplete = false; lock (_sync) { @@ -738,15 +682,11 @@ namespace System.Net.Quic.Implementations.MsQuic _receiveResettableCompletionSource.CompleteException(new QuicStreamAbortedException(_readErrorCode)); } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return MsQuicStatusCodes.Success; } private uint HandleEventPeerSendShutdown() { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - bool shouldComplete = false; lock (_sync) @@ -767,15 +707,11 @@ namespace System.Net.Quic.Implementations.MsQuic _receiveResettableCompletionSource.Complete(0); } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return MsQuicStatusCodes.Success; } private uint HandleEventSendComplete(ref StreamEvent evt) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Enter(this); - CleanupSendState(); // TODO throw if a write was canceled. @@ -796,8 +732,6 @@ namespace System.Net.Quic.Implementations.MsQuic _sendResettableCompletionSource.Complete(MsQuicStatusCodes.Success); } - if (NetEventSource.Log.IsEnabled()) NetEventSource.Exit(this); - return MsQuicStatusCodes.Success; }