diff --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h index 35773d5907e91..8c8424ed48154 100644 --- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -131,7 +131,7 @@ class ConnectionFileDescriptor : public Connection { lldb::IOObjectSP m_io_sp; Pipe m_pipe; - std::recursive_mutex m_mutex; + mutable std::recursive_mutex m_mutex; std::atomic m_shutting_down; // This marks that we are shutting down so // if we get woken up from // BytesAvailable to disconnect, we won't try to read again. diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 6a367a3307e54..9bb0268b2a704 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -118,6 +118,7 @@ void ConnectionFileDescriptor::CloseCommandPipe() { } bool ConnectionFileDescriptor::IsConnected() const { + std::lock_guard guard(m_mutex); return m_io_sp && m_io_sp->IsValid(); }