mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-12 00:07:24 -06:00
Reduce log spam on conhost exit (#18629)
When the server handle gets closed on conhost (= terminal is gone), and e.g. PowerShell is used, we would previously log 6 error messages. This PR reduces it to zero, by removing the 3 biggest offenders.
This commit is contained in:
parent
35bd60782f
commit
0df82681fe
@ -991,7 +991,7 @@ DWORD WINAPI ConsoleIoThread(LPVOID lpParameter)
|
|||||||
{
|
{
|
||||||
if (ReplyMsg != nullptr)
|
if (ReplyMsg != nullptr)
|
||||||
{
|
{
|
||||||
LOG_IF_FAILED(ReplyMsg->ReleaseMessageBuffers());
|
ReplyMsg->ReleaseMessageBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 9115192 correct mixed NTSTATUS/HRESULT
|
// TODO: 9115192 correct mixed NTSTATUS/HRESULT
|
||||||
|
|||||||
@ -180,12 +180,8 @@ CATCH_RETURN();
|
|||||||
// (if any) to the message.
|
// (if any) to the message.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// - <none>
|
// - <none>
|
||||||
// Return Value:
|
void _CONSOLE_API_MSG::ReleaseMessageBuffers()
|
||||||
// - HRESULT indicating if the payload was successfully written if applicable.
|
|
||||||
[[nodiscard]] HRESULT _CONSOLE_API_MSG::ReleaseMessageBuffers()
|
|
||||||
{
|
{
|
||||||
auto hr = S_OK;
|
|
||||||
|
|
||||||
if (State.InputBuffer != nullptr)
|
if (State.InputBuffer != nullptr)
|
||||||
{
|
{
|
||||||
_inputBuffer.clear();
|
_inputBuffer.clear();
|
||||||
@ -203,15 +199,15 @@ CATCH_RETURN();
|
|||||||
IoOperation.Buffer.Data = State.OutputBuffer;
|
IoOperation.Buffer.Data = State.OutputBuffer;
|
||||||
IoOperation.Buffer.Size = (ULONG)Complete.IoStatus.Information;
|
IoOperation.Buffer.Size = (ULONG)Complete.IoStatus.Information;
|
||||||
|
|
||||||
LOG_IF_FAILED(_pDeviceComm->WriteOutput(&IoOperation));
|
// This call fails when the server pipe is closed on us,
|
||||||
|
// which results in log spam in practice.
|
||||||
|
std::ignore = _pDeviceComm->WriteOutput(&IoOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
_outputBuffer.clear();
|
_outputBuffer.clear();
|
||||||
State.OutputBuffer = nullptr;
|
State.OutputBuffer = nullptr;
|
||||||
State.OutputBufferSize = 0;
|
State.OutputBufferSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _CONSOLE_API_MSG::SetReplyStatus(const NTSTATUS Status)
|
void _CONSOLE_API_MSG::SetReplyStatus(const NTSTATUS Status)
|
||||||
|
|||||||
@ -42,7 +42,7 @@ typedef struct _CONSOLE_API_MSG
|
|||||||
[[nodiscard]] HRESULT GetOutputBuffer(_Outptr_result_bytebuffer_(*pcbSize) void** const ppvBuffer, _Out_ ULONG* const pcbSize);
|
[[nodiscard]] HRESULT GetOutputBuffer(_Outptr_result_bytebuffer_(*pcbSize) void** const ppvBuffer, _Out_ ULONG* const pcbSize);
|
||||||
[[nodiscard]] HRESULT GetInputBuffer(_Outptr_result_bytebuffer_(*pcbSize) void** const ppvBuffer, _Out_ ULONG* const pcbSize);
|
[[nodiscard]] HRESULT GetInputBuffer(_Outptr_result_bytebuffer_(*pcbSize) void** const ppvBuffer, _Out_ ULONG* const pcbSize);
|
||||||
|
|
||||||
[[nodiscard]] HRESULT ReleaseMessageBuffers();
|
void ReleaseMessageBuffers();
|
||||||
|
|
||||||
void SetReplyStatus(const NTSTATUS Status);
|
void SetReplyStatus(const NTSTATUS Status);
|
||||||
void SetReplyInformation(const ULONG_PTR pInformation);
|
void SetReplyInformation(const ULONG_PTR pInformation);
|
||||||
|
|||||||
@ -137,14 +137,15 @@ ConDrvDeviceComm::~ConDrvDeviceComm() = default;
|
|||||||
// See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363216(v=vs.85).aspx
|
// See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363216(v=vs.85).aspx
|
||||||
// Written is unused but cannot be nullptr because we aren't using overlapped.
|
// Written is unused but cannot be nullptr because we aren't using overlapped.
|
||||||
DWORD cbWritten = 0;
|
DWORD cbWritten = 0;
|
||||||
RETURN_IF_WIN32_BOOL_FALSE(DeviceIoControl(_Server.get(),
|
RETURN_IF_WIN32_BOOL_FALSE_EXPECTED(DeviceIoControl(
|
||||||
dwIoControlCode,
|
_Server.get(),
|
||||||
pInBuffer,
|
dwIoControlCode,
|
||||||
cbInBufferSize,
|
pInBuffer,
|
||||||
pOutBuffer,
|
cbInBufferSize,
|
||||||
cbOutBufferSize,
|
pOutBuffer,
|
||||||
&cbWritten,
|
cbOutBufferSize,
|
||||||
nullptr));
|
&cbWritten,
|
||||||
|
nullptr));
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -223,9 +223,11 @@ bool ConsoleWaitBlock::Notify(const WaitTerminationReason TerminationReason)
|
|||||||
a->NumBytes = gsl::narrow<ULONG>(NumBytes);
|
a->NumBytes = gsl::narrow<ULONG>(NumBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_IF_FAILED(_WaitReplyMessage.ReleaseMessageBuffers());
|
_WaitReplyMessage.ReleaseMessageBuffers();
|
||||||
|
|
||||||
LOG_IF_FAILED(Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().pDeviceComm->CompleteIo(&_WaitReplyMessage.Complete));
|
// This call fails when the server pipe is closed on us,
|
||||||
|
// which results in log spam in practice.
|
||||||
|
std::ignore = Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().pDeviceComm->CompleteIo(&_WaitReplyMessage.Complete);
|
||||||
|
|
||||||
fRetVal = true;
|
fRetVal = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user