diff options
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/ScriptInterpreter.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp index a392d57..4424b6c 100644 --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -206,7 +206,8 @@ ScriptInterpreterIORedirect::Create(bool enable_io, Debugger &debugger, ScriptInterpreterIORedirect::ScriptInterpreterIORedirect( std::unique_ptr<File> input, std::unique_ptr<File> output) : m_input_file_sp(std::move(input)), - m_output_file_sp(std::make_shared<StreamFile>(std::move(output))), + m_output_file_sp(std::make_shared<LockableStreamFile>(std::move(output), + m_output_mutex)), m_error_file_sp(m_output_file_sp), m_communication("lldb.ScriptInterpreterIORedirect.comm"), m_disconnect(false) {} @@ -240,7 +241,9 @@ ScriptInterpreterIORedirect::ScriptInterpreterIORedirect( m_disconnect = true; FILE *outfile_handle = fdopen(pipe.ReleaseWriteFileDescriptor(), "w"); - m_output_file_sp = std::make_shared<StreamFile>(outfile_handle, true); + m_output_file_sp = std::make_shared<LockableStreamFile>( + std::make_shared<StreamFile>(outfile_handle, NativeFile::Owned), + m_output_mutex); m_error_file_sp = m_output_file_sp; if (outfile_handle) ::setbuf(outfile_handle, nullptr); @@ -257,9 +260,9 @@ ScriptInterpreterIORedirect::ScriptInterpreterIORedirect( void ScriptInterpreterIORedirect::Flush() { if (m_output_file_sp) - m_output_file_sp->Flush(); + m_output_file_sp->Lock().Flush(); if (m_error_file_sp) - m_error_file_sp->Flush(); + m_error_file_sp->Lock().Flush(); } ScriptInterpreterIORedirect::~ScriptInterpreterIORedirect() { @@ -273,7 +276,7 @@ ScriptInterpreterIORedirect::~ScriptInterpreterIORedirect() { // Close the write end of the pipe since we are done with our one line // script. This should cause the read thread that output_comm is using to // exit. - m_output_file_sp->GetFile().Close(); + m_output_file_sp->GetUnlockedFile().Close(); // The close above should cause this thread to exit when it gets to the end // of file, so let it get all its data. m_communication.JoinReadThread(); |