[Lldb-commits] [lldb] a9406da - [lldb] Add parts accidentally left out of 769d704: Recommit "[lldb/Core] Fix a race in the Communication class"

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 9 05:45:31 PDT 2020


Author: Pavel Labath
Date: 2020-04-09T14:45:23+02:00
New Revision: a9406daaa60f9899955a59c27f39db5519a97777

URL: https://github.com/llvm/llvm-project/commit/a9406daaa60f9899955a59c27f39db5519a97777
DIFF: https://github.com/llvm/llvm-project/commit/a9406daaa60f9899955a59c27f39db5519a97777.diff

LOG: [lldb] Add parts accidentally left out of 769d704: Recommit "[lldb/Core] Fix a race in the Communication class"

I went to a great length to explain the reason why these changes were
needed, but I did not actually ammend the patch to include them. :(

Added: 
    

Modified: 
    lldb/source/Core/Communication.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index c3e421191b01..2990f4157584 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -362,10 +362,17 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
   if (log)
     LLDB_LOGF(log, "%p Communication::ReadThread () thread exiting...", p);
 
-  comm->BroadcastEvent(eBroadcastBitNoMorePendingInput);
+  // Handle threads wishing to synchronize with us.
   {
-    std::lock_guard<std::mutex> guard(comm->m_synchronize_mutex);
+    // Prevent new ones from showing up.
     comm->m_read_thread_did_exit = true;
+
+    // Unblock any existing thread waiting for the synchronization signal.
+    comm->BroadcastEvent(eBroadcastBitNoMorePendingInput);
+
+    // Wait for the thread to finish...
+    std::lock_guard<std::mutex> guard(comm->m_synchronize_mutex);
+    // ... and disconnect.
     if (disconnect)
       comm->Disconnect();
   }


        


More information about the lldb-commits mailing list