parent
adb12f23d0
commit
c7937640a4
|
|
@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
|
||||
Options = options;
|
||||
|
||||
Logger = LogHelper.CreateLogger(loggerFactory, typeof(HttpSysListener));
|
||||
Logger = loggerFactory.CreateLogger<HttpSysListener>();
|
||||
|
||||
_state = State.Stopped;
|
||||
_internalLock = new object();
|
||||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
_requestQueue?.Dispose();
|
||||
_urlGroup?.Dispose();
|
||||
_serverSession?.Dispose();
|
||||
LogHelper.LogException(Logger, ".Ctor", exception);
|
||||
Logger.LogError(0, exception, ".Ctor");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
CheckDisposed();
|
||||
|
||||
LogHelper.LogTrace(Logger, "Starting the listener.");
|
||||
Logger.LogTrace("Starting the listener.");
|
||||
|
||||
// Make sure there are no race conditions between Start/Stop/Abort/Close/Dispose.
|
||||
// Start needs to setup all resources. Abort/Stop must not interfere while Start is
|
||||
|
|
@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
// Make sure the HttpListener instance can't be used if Start() failed.
|
||||
_state = State.Disposed;
|
||||
DisposeInternal();
|
||||
LogHelper.LogException(Logger, "Start", exception);
|
||||
Logger.LogError(0, exception, "Start");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
return;
|
||||
}
|
||||
|
||||
LogHelper.LogTrace(Logger, "Stopping the listener.");
|
||||
Logger.LogTrace("Stopping the listener.");
|
||||
|
||||
// If this instance created the queue then remove the URL prefixes before shutting down.
|
||||
if (_requestQueue.Created)
|
||||
|
|
@ -210,7 +210,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.LogException(Logger, "Stop", exception);
|
||||
Logger.LogError(0, exception, "Stop");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
@ -238,14 +238,14 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
return;
|
||||
}
|
||||
LogHelper.LogTrace(Logger, "Disposing the listener.");
|
||||
Logger.LogTrace("Disposing the listener.");
|
||||
|
||||
Stop();
|
||||
DisposeInternal();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.LogException(Logger, "Dispose", exception);
|
||||
Logger.LogError(0, exception, "Dispose");
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
|
|
@ -300,7 +300,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.LogException(Logger, "GetContextAsync", exception);
|
||||
Logger.LogError(0, exception, "GetContextAsync");
|
||||
throw;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,118 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.HttpSys
|
||||
{
|
||||
internal static class LogHelper
|
||||
{
|
||||
internal static ILogger CreateLogger(ILoggerFactory factory, Type type)
|
||||
{
|
||||
if (factory == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return factory.CreateLogger(type.FullName);
|
||||
}
|
||||
|
||||
internal static void LogInfo(ILogger logger, string data)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
Debug.WriteLine(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogInformation(data);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LogWarning(ILogger logger, string data)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
Debug.WriteLine(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogWarning(data);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LogDebug(ILogger logger, string data)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
Debug.WriteLine(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogDebug(data);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LogDebug(ILogger logger, string location, string data)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
Debug.WriteLine(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogDebug(location + "; " + data);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LogDebug(ILogger logger, string location, Exception exception)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
Debug.WriteLine(location + Environment.NewLine + exception.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogDebug(0, exception, location);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LogTrace(ILogger logger, string data)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
Debug.WriteLine(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogTrace(data);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LogException(ILogger logger, string location, Exception exception)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
Debug.WriteLine(location + Environment.NewLine + exception.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogError(0, exception, location);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void LogError(ILogger logger, string location, string message)
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
Debug.WriteLine(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogError(location + "; " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
_options = options.Value;
|
||||
Listener = new HttpSysListener(_options, loggerFactory);
|
||||
_logger = LogHelper.CreateLogger(loggerFactory, typeof(MessagePump));
|
||||
_logger = loggerFactory.CreateLogger<MessagePump>();
|
||||
|
||||
if (_options.Authentication.Schemes != AuthenticationSchemes.None)
|
||||
{
|
||||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
if (_options.UrlPrefixes.Count > 0)
|
||||
{
|
||||
LogHelper.LogWarning(_logger, $"Overriding endpoints added to {nameof(HttpSysOptions.UrlPrefixes)} since {nameof(IServerAddressesFeature.PreferHostingUrls)} is set to true." +
|
||||
_logger.LogWarning($"Overriding endpoints added to {nameof(HttpSysOptions.UrlPrefixes)} since {nameof(IServerAddressesFeature.PreferHostingUrls)} is set to true." +
|
||||
$" Binding to address(es) '{string.Join(", ", _serverAddresses.Addresses)}' instead. ");
|
||||
|
||||
Listener.Options.UrlPrefixes.Clear();
|
||||
|
|
@ -95,7 +95,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
if (hostingUrlsPresent)
|
||||
{
|
||||
LogHelper.LogWarning(_logger, $"Overriding address(es) '{string.Join(", ", _serverAddresses.Addresses)}'. " +
|
||||
_logger.LogWarning($"Overriding address(es) '{string.Join(", ", _serverAddresses.Addresses)}'. " +
|
||||
$"Binding to endpoints added to {nameof(HttpSysOptions.UrlPrefixes)} instead.");
|
||||
|
||||
_serverAddresses.Addresses.Clear();
|
||||
|
|
@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
else if (Listener.RequestQueue.Created)
|
||||
{
|
||||
LogHelper.LogDebug(_logger, $"No listening endpoints were configured. Binding to {Constants.DefaultServerAddress} by default.");
|
||||
_logger.LogDebug($"No listening endpoints were configured. Binding to {Constants.DefaultServerAddress} by default.");
|
||||
|
||||
Listener.Options.UrlPrefixes.Add(Constants.DefaultServerAddress);
|
||||
}
|
||||
|
|
@ -171,11 +171,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
Contract.Assert(Stopping);
|
||||
if (Stopping)
|
||||
{
|
||||
LogHelper.LogDebug(_logger, "ListenForNextRequestAsync-Stopping", exception);
|
||||
_logger.LogDebug(0, exception, "ListenForNextRequestAsync-Stopping");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.LogException(_logger, "ListenForNextRequestAsync", exception);
|
||||
_logger.LogError(0, exception, "ListenForNextRequestAsync");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
// Request processing failed to be queued in threadpool
|
||||
// Log the error message, release throttle and move on
|
||||
LogHelper.LogException(_logger, "ProcessRequestAsync", ex);
|
||||
_logger.LogError(0, ex, "ProcessRequestAsync");
|
||||
}
|
||||
}
|
||||
Interlocked.Decrement(ref _acceptorCounts);
|
||||
|
|
@ -224,7 +224,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.LogException(_logger, "ProcessRequestAsync", ex);
|
||||
_logger.LogError(0, ex, "ProcessRequestAsync");
|
||||
_application.DisposeContext(context, ex);
|
||||
if (requestContext.Response.HasStarted)
|
||||
{
|
||||
|
|
@ -247,14 +247,14 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
if (Interlocked.Decrement(ref _outstandingRequests) == 0 && Stopping)
|
||||
{
|
||||
LogHelper.LogInfo(_logger, "All requests drained.");
|
||||
_logger.LogInformation("All requests drained.");
|
||||
_shutdownSignal.TrySetResult(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.LogException(_logger, "ProcessRequestAsync", ex);
|
||||
_logger.LogError(0, ex, "ProcessRequestAsync");
|
||||
requestContext.Abort();
|
||||
}
|
||||
}
|
||||
|
|
@ -274,7 +274,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
if (Interlocked.Exchange(ref _shutdownSignalCompleted, 1) == 0)
|
||||
{
|
||||
LogHelper.LogInfo(_logger, "Canceled, terminating " + _outstandingRequests + " request(s).");
|
||||
_logger.LogInformation("Canceled, terminating " + _outstandingRequests + " request(s).");
|
||||
_shutdownSignal.TrySetResult(null);
|
||||
}
|
||||
});
|
||||
|
|
@ -292,7 +292,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
// Wait for active requests to drain
|
||||
if (_outstandingRequests > 0)
|
||||
{
|
||||
LogHelper.LogInfo(_logger, "Stopping, waiting for " + _outstandingRequests + " request(s) to drain.");
|
||||
_logger.LogInformation("Stopping, waiting for " + _outstandingRequests + " request(s) to drain.");
|
||||
RegisterCancelation();
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (Win32Exception exception)
|
||||
{
|
||||
LogHelper.LogException(_logger, "GetConnectionToken", exception);
|
||||
_logger.LogError(0, exception, "GetConnectionToken");
|
||||
return CancellationToken.None;
|
||||
}
|
||||
}
|
||||
|
|
@ -54,12 +54,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
// Race condition on creation has no side effects
|
||||
var cancellation = new ConnectionCancellation(this);
|
||||
return _connectionCancellationTokens.GetOrAdd(connectionId, cancellation);
|
||||
return _connectionCancellationTokens.GetOrAdd(connectionId, cancellation);
|
||||
}
|
||||
|
||||
private unsafe CancellationToken CreateDisconnectToken(ulong connectionId)
|
||||
{
|
||||
LogHelper.LogDebug(_logger, "CreateDisconnectToken", "Registering connection for disconnect for connection ID: " + connectionId);
|
||||
_logger.LogDebug("CreateDisconnectToken; Registering connection for disconnect for connection ID: " + connectionId);
|
||||
|
||||
// Create a nativeOverlapped callback so we can register for disconnect callback
|
||||
var cts = new CancellationTokenSource();
|
||||
|
|
@ -70,8 +70,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
nativeOverlapped = new SafeNativeOverlapped(boundHandle, boundHandle.AllocateNativeOverlapped(
|
||||
(errorCode, numBytes, overlappedPtr) =>
|
||||
{
|
||||
LogHelper.LogDebug(_logger, "CreateDisconnectToken", "http.sys disconnect callback fired for connection ID: " + connectionId);
|
||||
|
||||
_logger.LogDebug("CreateDisconnectToken; http.sys disconnect callback fired for connection ID: " + connectionId);
|
||||
|
||||
// Free the overlapped
|
||||
nativeOverlapped.Dispose();
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (AggregateException exception)
|
||||
{
|
||||
LogHelper.LogException(_logger, "CreateDisconnectToken Callback", exception);
|
||||
_logger.LogError(0, exception, "CreateDisconnectToken Callback");
|
||||
}
|
||||
},
|
||||
null, null));
|
||||
|
|
@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
catch (Win32Exception exception)
|
||||
{
|
||||
statusCode = (uint)exception.NativeErrorCode;
|
||||
LogHelper.LogException(_logger, "CreateDisconnectToken", exception);
|
||||
_logger.LogError(0, exception, "CreateDisconnectToken");
|
||||
}
|
||||
|
||||
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_IO_PENDING &&
|
||||
|
|
@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
nativeOverlapped.Dispose();
|
||||
ConnectionCancellation ignored;
|
||||
_connectionCancellationTokens.TryRemove(connectionId, out ignored);
|
||||
LogHelper.LogDebug(_logger, "HttpWaitForDisconnectEx", new Win32Exception((int)statusCode));
|
||||
_logger.LogDebug(0, new Win32Exception((int)statusCode), "HttpWaitForDisconnectEx");
|
||||
cts.Cancel();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
|
||||
internal void SetProperty(HttpApiTypes.HTTP_SERVER_PROPERTY property, IntPtr info, uint infosize, bool throwOnError = true)
|
||||
{
|
||||
{
|
||||
Debug.Assert(info != IntPtr.Zero, "SetUrlGroupProperty called with invalid pointer");
|
||||
CheckDisposed();
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
|
||||
{
|
||||
var exception = new HttpSysException((int)statusCode);
|
||||
LogHelper.LogException(_logger, "SetUrlGroupProperty", exception);
|
||||
_logger.LogError(0, exception, "SetUrlGroupProperty");
|
||||
if (throwOnError)
|
||||
{
|
||||
throw exception;
|
||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
|
||||
internal void RegisterPrefix(string uriPrefix, int contextId)
|
||||
{
|
||||
LogHelper.LogDebug(_logger, "Listening on prefix: " + uriPrefix);
|
||||
_logger.LogDebug("Listening on prefix: " + uriPrefix);
|
||||
CheckDisposed();
|
||||
var statusCode = HttpApi.HttpAddUrlToUrlGroup(Id, uriPrefix, (ulong)contextId, 0);
|
||||
|
||||
|
|
@ -87,10 +87,10 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal bool UnregisterPrefix(string uriPrefix)
|
||||
{
|
||||
LogHelper.LogDebug(_logger, "Stop listening on prefix: " + uriPrefix);
|
||||
_logger.LogInformation("Stop listening on prefix: " + uriPrefix);
|
||||
CheckDisposed();
|
||||
|
||||
var statusCode = HttpApi.HttpRemoveUrlFromUrlGroup(Id, uriPrefix, 0);
|
||||
|
|
@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
|
||||
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
|
||||
{
|
||||
LogHelper.LogError(_logger, "CleanupV2Config", "Result: " + statusCode);
|
||||
_logger.LogError("CleanupV2Config; Result: " + statusCode);
|
||||
}
|
||||
Id = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,13 +400,13 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
else if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_INVALID_PARAMETER)
|
||||
{
|
||||
LogHelper.LogError(logger, "GetChannelBindingFromTls", "Channel binding is not supported.");
|
||||
logger.LogError("GetChannelBindingFromTls; Channel binding is not supported.");
|
||||
return null; // old schannel library which doesn't support CBT
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's up to the consumer to fail if the missing ChannelBinding matters to them.
|
||||
LogHelper.LogException(logger, "GetChannelBindingFromTls", new HttpSysException((int)statusCode));
|
||||
logger.LogError(0, new HttpSysException((int)statusCode), "GetChannelBindingFromTls");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,14 +120,14 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
if (!Request.IsHttps)
|
||||
{
|
||||
LogHelper.LogDebug(Logger, "TryGetChannelBinding", "Channel binding requires HTTPS.");
|
||||
Logger.LogDebug("TryGetChannelBinding; Channel binding requires HTTPS.");
|
||||
return false;
|
||||
}
|
||||
|
||||
value = ClientCertLoader.GetChannelBindingFromTls(Server.RequestQueue, Request.UConnectionId, Logger);
|
||||
|
||||
Debug.Assert(value != null, "GetChannelBindingFromTls returned null even though OS supposedly supports Extended Protection");
|
||||
LogHelper.LogInfo(Logger, "Channel binding retrieved.");
|
||||
Logger.LogInformation("Channel binding retrieved.");
|
||||
return value != null;
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.LogDebug(Logger, "Abort", ex);
|
||||
Logger.LogDebug(0, ex, "Abort");
|
||||
}
|
||||
_requestAbortSource.Dispose();
|
||||
}
|
||||
|
|
@ -231,7 +231,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
try
|
||||
{
|
||||
var streamError = new HttpApiTypes.HTTP_REQUEST_PROPERTY_STREAM_ERROR() { ErrorCode = (uint)errorCode };
|
||||
var statusCode = HttpApi.HttpSetRequestProperty(Server.RequestQueue.Handle, Request.RequestId, HttpApiTypes.HTTP_REQUEST_PROPERTY.HttpRequestPropertyStreamError, (void*)&streamError,
|
||||
var statusCode = HttpApi.HttpSetRequestProperty(Server.RequestQueue.Handle, Request.RequestId, HttpApiTypes.HTTP_REQUEST_PROPERTY.HttpRequestPropertyStreamError, (void*)&streamError,
|
||||
(uint)sizeof(HttpApiTypes.HTTP_REQUEST_PROPERTY_STREAM_ERROR), IntPtr.Zero);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
|
||||
{
|
||||
Exception exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
|
||||
LogHelper.LogException(Logger, "Read", exception);
|
||||
Logger.LogError(0, exception, "Read");
|
||||
Abort();
|
||||
throw exception;
|
||||
}
|
||||
|
|
@ -242,7 +242,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.LogException(Logger, "BeginRead", e);
|
||||
Logger.LogError(0, e, "BeginRead");
|
||||
asyncResult.Dispose();
|
||||
throw;
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
else
|
||||
{
|
||||
Exception exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
|
||||
LogHelper.LogException(Logger, "BeginRead", exception);
|
||||
Logger.LogError(0, exception, "BeginRead");
|
||||
Abort();
|
||||
throw exception;
|
||||
}
|
||||
|
|
@ -365,7 +365,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
asyncResult.Dispose();
|
||||
Abort();
|
||||
LogHelper.LogException(Logger, "ReadAsync", e);
|
||||
Logger.LogError(0, e, "ReadAsync");
|
||||
throw;
|
||||
}
|
||||
|
||||
|
|
@ -386,7 +386,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
else
|
||||
{
|
||||
Exception exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
|
||||
LogHelper.LogException(Logger, "ReadAsync", exception);
|
||||
Logger.LogError(0, exception, "ReadAsync");
|
||||
Abort();
|
||||
throw exception;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
if (!RequestContext.DisconnectToken.IsCancellationRequested)
|
||||
{
|
||||
// This is logged rather than thrown because it is too late for an exception to be visible in user code.
|
||||
LogHelper.LogError(Logger, "ResponseStream::Dispose", "Fewer bytes were written than were specified in the Content-Length.");
|
||||
Logger.LogError("ResponseStream::Dispose; Fewer bytes were written than were specified in the Content-Length.");
|
||||
}
|
||||
_requestContext.Abort();
|
||||
return;
|
||||
|
|
@ -175,14 +175,14 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
if (ThrowWriteExceptions)
|
||||
{
|
||||
var exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
|
||||
LogHelper.LogException(Logger, "Flush", exception);
|
||||
Logger.LogError(0, exception, "Flush");
|
||||
Abort();
|
||||
throw exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Abort the request but do not close the stream, let future writes complete silently
|
||||
LogHelper.LogDebug(Logger, "Flush", $"Ignored write exception: {statusCode}");
|
||||
Logger.LogDebug($"Flush; Ignored write exception: {statusCode}");
|
||||
Abort(dispose: false);
|
||||
}
|
||||
}
|
||||
|
|
@ -345,7 +345,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.LogException(Logger, "FlushAsync", e);
|
||||
Logger.LogError(0, e, "FlushAsync");
|
||||
asyncResult.Dispose();
|
||||
Abort();
|
||||
throw;
|
||||
|
|
@ -355,21 +355,21 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
LogHelper.LogDebug(Logger, "FlushAsync", $"Write cancelled with error code: {statusCode}");
|
||||
Logger.LogDebug($"FlushAsync; Write cancelled with error code: {statusCode}");
|
||||
asyncResult.Cancel(ThrowWriteExceptions);
|
||||
}
|
||||
else if (ThrowWriteExceptions)
|
||||
{
|
||||
asyncResult.Dispose();
|
||||
Exception exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
|
||||
LogHelper.LogException(Logger, "FlushAsync", exception);
|
||||
Logger.LogError(0, exception, "FlushAsync");
|
||||
Abort();
|
||||
throw exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Abort the request but do not close the stream, let future writes complete silently
|
||||
LogHelper.LogDebug(Logger, "FlushAsync", $"Ignored write exception: {statusCode}");
|
||||
Logger.LogDebug($"FlushAsync; Ignored write exception: {statusCode}");
|
||||
asyncResult.FailSilently();
|
||||
}
|
||||
}
|
||||
|
|
@ -639,7 +639,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.LogException(Logger, "SendFileAsync", e);
|
||||
Logger.LogError(0, e, "SendFileAsync");
|
||||
asyncResult.Dispose();
|
||||
Abort();
|
||||
throw;
|
||||
|
|
@ -649,21 +649,21 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
LogHelper.LogDebug(Logger, "SendFileAsync", $"Write cancelled with error code: {statusCode}");
|
||||
Logger.LogDebug($"SendFileAsync; Write cancelled with error code: {statusCode}");
|
||||
asyncResult.Cancel(ThrowWriteExceptions);
|
||||
}
|
||||
else if (ThrowWriteExceptions)
|
||||
{
|
||||
asyncResult.Dispose();
|
||||
var exception = new IOException(string.Empty, new HttpSysException((int)statusCode));
|
||||
LogHelper.LogException(Logger, "SendFileAsync", exception);
|
||||
Logger.LogError(0, exception, "SendFileAsync");
|
||||
Abort();
|
||||
throw exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Abort the request but do not close the stream, let future writes complete silently
|
||||
LogHelper.LogDebug(Logger, "SendFileAsync", $"Ignored write exception: {statusCode}");
|
||||
Logger.LogDebug($"SendFileAsync; Ignored write exception: {statusCode}");
|
||||
asyncResult.FailSilently();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.HttpSys.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.HttpSys
|
||||
{
|
||||
|
|
@ -232,18 +233,18 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
{
|
||||
if (asyncResult._cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
LogHelper.LogDebug(logger, "FlushAsync.IOCompleted", $"Write cancelled with error code: {errorCode}");
|
||||
logger.LogDebug($"FlushAsync.IOCompleted; Write cancelled with error code: {errorCode}");
|
||||
asyncResult.Cancel(asyncResult._responseStream.ThrowWriteExceptions);
|
||||
}
|
||||
else if (asyncResult._responseStream.ThrowWriteExceptions)
|
||||
{
|
||||
var exception = new IOException(string.Empty, new HttpSysException((int)errorCode));
|
||||
LogHelper.LogException(logger, "FlushAsync.IOCompleted", exception);
|
||||
logger.LogError(0, exception, "FlushAsync.IOCompleted");
|
||||
asyncResult.Fail(exception);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.LogDebug(logger, "FlushAsync.IOCompleted", $"Ignored write exception: {errorCode}");
|
||||
logger.LogDebug($"FlushAsync.IOCompleted; Ignored write exception: {errorCode}");
|
||||
asyncResult.FailSilently();
|
||||
}
|
||||
}
|
||||
|
|
@ -258,7 +259,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
// TODO: Verbose log
|
||||
// for (int i = 0; i < asyncResult._dataChunks.Length; i++)
|
||||
// {
|
||||
// Logging.Dump(Logging.HttpListener, asyncResult, "Callback", (IntPtr)asyncResult._dataChunks[0].fromMemory.pBuffer, (int)asyncResult._dataChunks[0].fromMemory.BufferLength);
|
||||
// Logging.Dump(Logging.HttpListener, asyncResult, "Callback", (IntPtr)asyncResult._dataChunks[0].fromMemory.pBuffer, (int)asyncResult._dataChunks[0].fromMemory.BufferLength);
|
||||
// }
|
||||
}
|
||||
asyncResult.Complete();
|
||||
|
|
@ -266,7 +267,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.LogException(logger, "FlushAsync.IOCompleted", e);
|
||||
logger.LogError(0, e, "FlushAsync.IOCompleted");
|
||||
asyncResult.Fail(e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue