Cleaned up the Communication class when it tears down ConnectionFileDescriptor
instances to not pthread_cancel the read threads and wreak havoc on the mutex
in our ConnectionFileDescriptor class.

Also cleaned up some shutdown delays.

llvm-svn: 149355
diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index a9ca35c..45850f3 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -65,8 +65,8 @@
 Communication::Clear()
 {
     SetReadThreadBytesReceivedCallback (NULL, NULL);
-    StopReadThread (NULL);
     Disconnect (NULL);
+    StopReadThread (NULL);
 }
 
 ConnectionStatus
@@ -253,7 +253,7 @@
 
     BroadcastEvent (eBroadcastBitReadThreadShouldExit, NULL);
 
-    Host::ThreadCancel (m_read_thread, error_ptr);
+    //Host::ThreadCancel (m_read_thread, error_ptr);
 
     bool status = Host::ThreadJoin (m_read_thread, NULL, error_ptr);
     m_read_thread = LLDB_INVALID_HOST_THREAD;
@@ -383,7 +383,7 @@
     // Let clients know that this thread is exiting
     comm->BroadcastEvent (eBroadcastBitReadThreadDidExit);
     comm->m_read_thread_enabled = false;
-    comm->Disconnect();
+    comm->m_read_thread = LLDB_INVALID_HOST_THREAD;
     return NULL;
 }
 
@@ -401,8 +401,8 @@
 void
 Communication::SetConnection (Connection *connection)
 {
-    StopReadThread(NULL);
     Disconnect (NULL);
+    StopReadThread(NULL);
     m_connection_sp.reset(connection);
 }