Fix up how we shut down the communication with debugserver so we don't rely on
debugserver being responsive to shut down.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@143174 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 917fc4d..7f842c2 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1511,9 +1511,6 @@
     // Sleep for one second to let the process get all detached...
     StopAsyncThread ();
 
-    m_gdb_comm.StopReadThread();
-    m_gdb_comm.Disconnect();    // Disconnect from the debug server.
-
     SetPrivateState (eStateDetached);
     ResumePrivateStateThread();
 
@@ -1532,13 +1529,7 @@
     // Interrupt if our inferior is running...
     if (m_gdb_comm.IsConnected())
     {
-        if (m_public_state.GetValue() == eStateAttaching)
-        {
-            // We are being asked to halt during an attach. We need to just close
-            // our file handle and debugserver will go away, and we can be done...
-            m_gdb_comm.Disconnect();
-        }
-        else
+        if (m_public_state.GetValue() != eStateAttaching)
         {
 
             StringExtractorGDBRemote response;
@@ -1561,9 +1552,7 @@
         }
     }
     StopAsyncThread ();
-    m_gdb_comm.StopReadThread();
     KillDebugserverProcess ();
-    m_gdb_comm.Disconnect();    // Disconnect from the debug server.
     return error;
 }
 
@@ -2294,6 +2283,9 @@
         log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__);
 
     m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit);
+    
+    //  This will shut down the async thread.
+    m_gdb_comm.Disconnect();    // Disconnect from the debug server.
 
     // Stop the stdio thread
     if (IS_VALID_LLDB_HOST_THREAD(m_async_thread))