Skip to content

Commit

Permalink
Fix lock warning during ReturnResponse (#17266)
Browse files Browse the repository at this point in the history
As reported here:
#16224 (comment)

The underlying `WriteFile` call may block indefinitely and
we shouldn't hold the terminal lock during that period.
  • Loading branch information
lhecker committed May 15, 2024
1 parent 9054c81 commit 183a895
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 183a895

Please sign in to comment.