Fix lock warning during ReturnResponse (#17266)

As reported here:
https://github.com/microsoft/terminal/pull/16224#discussion_r1594849244

The underlying `WriteFile` call may block indefinitely and
we shouldn't hold the terminal lock during that period.
This commit is contained in:
Leonard Hecker 2024-05-16 00:03:28 +02:00 committed by GitHub
parent 9054c81934
commit 183a8956f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,8 +22,9 @@ TRACELOGGING_DEFINE_PROVIDER(g_hCTerminalCoreProvider,
void Terminal::ReturnResponse(const std::wstring_view response)
{
if (_pfnWriteInput)
if (_pfnWriteInput && !response.empty())
{
const auto suspension = _readWriteLock.suspend();
_pfnWriteInput(response);
}
}