summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Communication.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-12-12 21:50:57 +0000
committerGreg Clayton <gclayton@apple.com>2010-12-12 21:50:57 +0000
commitbfae66ae1d5a8d317505c5b08cee6cb64e621a98 (patch)
treecbf1c3c0e251149c170434a4c5afb3613483bf7d /lldb/source/Core/Communication.cpp
parent5be5391df0d54e8f26645df9352a8a868fb25bd7 (diff)
downloadbcm5719-llvm-bfae66ae1d5a8d317505c5b08cee6cb64e621a98.tar.gz
bcm5719-llvm-bfae66ae1d5a8d317505c5b08cee6cb64e621a98.zip
Fixed a multi-threaded race condition that could happen when communication classes are shutting down. We currently don't protect communication connection classes against multi-threaded access. The connection is stored in the lldb_private::Communication.m_connection_ap auto_ptr member. We either need to add protections when accessing this class or not let anything racy occur. With this fix, we are doing the latter.
llvm-svn: 121647
Diffstat (limited to 'lldb/source/Core/Communication.cpp')
-rw-r--r--lldb/source/Core/Communication.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index f6100d74f39..3ecdb4e8ec0 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -94,7 +94,16 @@ Communication::Disconnect (Error *error_ptr)
if (m_connection_ap.get())
{
ConnectionStatus status = m_connection_ap->Disconnect (error_ptr);
- m_connection_ap.reset();
+ // We currently don't protect m_connection_ap with any mutex for
+ // multi-threaded environments. So lets not nuke our connection class
+ // without putting some multi-threaded protections in. We also probably
+ // don't want to pay for the overhead it might cause if every time we
+ // access the connection we have to take a lock.
+ //
+ // This auto_ptr will cleanup after itself when this object goes away,
+ // so there is no need to currently have it destroy itself immediately
+ // upon disconnnect.
+ //m_connection_ap.reset();
return status;
}
return eConnectionStatusNoConnection;
@@ -347,6 +356,7 @@ Communication::ReadThread (void *p)
// Let clients know that this thread is exiting
comm->BroadcastEvent (eBroadcastBitReadThreadDidExit);
comm->m_read_thread = LLDB_INVALID_HOST_THREAD;
+ comm->Disconnect();
return NULL;
}
OpenPOWER on IntegriCloud