Lower log severity for opening internal libuv pipe (#6636)
Addresses #4741
This commit is contained in:
parent
7f7723bdf2
commit
cd0eab88ea
|
|
@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
dispatchPipe.Init(Thread.Loop, Thread.QueueCloseHandle, true);
|
||||
pipe.Accept(dispatchPipe);
|
||||
|
||||
// Ensure client sends "Kestrel" before adding pipe to _dispatchPipes.
|
||||
// Ensure client sends _pipeMessage before adding pipe to _dispatchPipes.
|
||||
var readContext = new PipeReadContext(this);
|
||||
dispatchPipe.ReadStart(
|
||||
(handle, status2, state) => ((PipeReadContext)state).AllocCallback(handle, status2),
|
||||
|
|
@ -228,6 +228,18 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
|
||||
public void ReadCallback(UvStreamHandle dispatchPipe, int status)
|
||||
{
|
||||
if (status == LibuvConstants.EOF && _bytesRead == 0)
|
||||
{
|
||||
// This is an unexpected immediate termination of the dispatch pipe most likely caused by an
|
||||
// external process scanning the pipe, so don't we don't log it too severely.
|
||||
// https://github.com/aspnet/AspNetCore/issues/4741
|
||||
|
||||
dispatchPipe.Dispose();
|
||||
_bufHandle.Free();
|
||||
_listener.Log.LogDebug("An internal pipe was opened unexpectedly.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
dispatchPipe.Libuv.ThrowIfErrored(status);
|
||||
|
|
@ -254,7 +266,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new IOException("Bad data sent over Kestrel pipe.");
|
||||
throw new IOException("Bad data sent over an internal pipe.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -196,9 +196,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
await listenerPrimary.DisposeAsync();
|
||||
await libuvThreadPrimary.StopAsync(TimeSpan.FromSeconds(5));
|
||||
|
||||
Assert.Equal(1, logger.TotalErrorsLogged);
|
||||
var errorMessage = logger.Messages.First(m => m.LogLevel == LogLevel.Error);
|
||||
Assert.Equal(TestConstants.EOF, Assert.IsType<UvException>(errorMessage.Exception).StatusCode);
|
||||
Assert.Equal(0, logger.TotalErrorsLogged);
|
||||
|
||||
var logMessage = logger.Messages.Single(m => m.Message == "An internal pipe was opened unexpectedly.");
|
||||
Assert.Equal(LogLevel.Debug, logMessage.LogLevel);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue