summaryrefslogtreecommitdiff
path: root/source/Host/posix/ConnectionFileDescriptorPosix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Host/posix/ConnectionFileDescriptorPosix.cpp')
-rw-r--r--source/Host/posix/ConnectionFileDescriptorPosix.cpp57
1 files changed, 27 insertions, 30 deletions
diff --git a/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index dbbd5a1dcc3c..52d65b1e9a97 100644
--- a/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -79,12 +79,12 @@ GetURLAddress(const char *url, const char *scheme)
}
ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
- : Connection()
- , m_pipe()
- , m_mutex(Mutex::eMutexTypeRecursive)
- , m_shutting_down(false)
- , m_waiting_for_accept(false)
- , m_child_processes_inherit(child_processes_inherit)
+ : Connection(),
+ m_pipe(),
+ m_mutex(),
+ m_shutting_down(false),
+ m_waiting_for_accept(false),
+ m_child_processes_inherit(child_processes_inherit)
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log)
@@ -92,30 +92,30 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
}
ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd)
- : Connection()
- , m_pipe()
- , m_mutex(Mutex::eMutexTypeRecursive)
- , m_shutting_down(false)
- , m_waiting_for_accept(false)
- , m_child_processes_inherit(false)
+ : Connection(),
+ m_pipe(),
+ m_mutex(),
+ m_shutting_down(false),
+ m_waiting_for_accept(false),
+ m_child_processes_inherit(false)
{
m_write_sp.reset(new File(fd, owns_fd));
m_read_sp.reset(new File(fd, false));
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log)
- log->Printf("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", static_cast<void *>(this), fd,
- owns_fd);
+ log->Printf("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)",
+ static_cast<void *>(this), fd, owns_fd);
OpenCommandPipe();
}
-ConnectionFileDescriptor::ConnectionFileDescriptor(Socket* socket)
- : Connection()
- , m_pipe()
- , m_mutex(Mutex::eMutexTypeRecursive)
- , m_shutting_down(false)
- , m_waiting_for_accept(false)
- , m_child_processes_inherit(false)
+ConnectionFileDescriptor::ConnectionFileDescriptor(Socket *socket)
+ : Connection(),
+ m_pipe(),
+ m_mutex(),
+ m_shutting_down(false),
+ m_waiting_for_accept(false),
+ m_child_processes_inherit(false)
{
InitializeSocket(socket);
}
@@ -170,7 +170,7 @@ ConnectionFileDescriptor::IsConnected() const
ConnectionStatus
ConnectionFileDescriptor::Connect(const char *s, Error *error_ptr)
{
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf("%p ConnectionFileDescriptor::Connect (url = '%s')", static_cast<void *>(this), s);
@@ -374,10 +374,8 @@ ConnectionFileDescriptor::Disconnect(Error *error_ptr)
m_shutting_down = true;
- Mutex::Locker locker;
- bool got_lock = locker.TryLock(m_mutex);
-
- if (!got_lock)
+ std::unique_lock<std::recursive_mutex> locker(m_mutex, std::defer_lock);
+ if (!locker.try_lock())
{
if (m_pipe.CanWrite())
{
@@ -392,7 +390,7 @@ ConnectionFileDescriptor::Disconnect(Error *error_ptr)
log->Printf("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, but no command pipe is available.",
static_cast<void *>(this));
}
- locker.Lock(m_mutex);
+ locker.lock();
}
Error error = m_read_sp->Close();
@@ -415,9 +413,8 @@ ConnectionFileDescriptor::Read(void *dst, size_t dst_len, uint32_t timeout_usec,
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
- Mutex::Locker locker;
- bool got_lock = locker.TryLock(m_mutex);
- if (!got_lock)
+ std::unique_lock<std::recursive_mutex> locker(m_mutex, std::defer_lock);
+ if (!locker.try_lock())
{
if (log)
log->Printf("%p ConnectionFileDescriptor::Read () failed to get the connection lock.", static_cast<void *>(this));