From 26661bca2075d2cab6c7d0106141c8892ecd1cbd Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 23 Jul 2010 15:43:25 +0000 Subject: [PATCH] Remove a premature invalidation of a threads pthread_t handle, thus avoiding a segfault when calling pthread_cancel. Also, sets m_read_thread_enabled if the thread is actually spawned. Patch from Stephen Wilson. llvm-svn: 109227 --- lldb/source/Core/Communication.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp index 9fa06479511d..d05eb3b1556f 100644 --- a/lldb/source/Core/Communication.cpp +++ b/lldb/source/Core/Communication.cpp @@ -211,9 +211,9 @@ Communication::StartReadThread (Error *error_ptr) char thread_name[1024]; snprintf(thread_name, sizeof(thread_name), "", m_broadcaster_name.AsCString()); - m_read_thread_enabled = true; m_read_thread = Host::ThreadCreate (thread_name, Communication::ReadThread, this, error_ptr); - return m_read_thread != LLDB_INVALID_HOST_THREAD; + m_read_thread_enabled = m_read_thread != LLDB_INVALID_HOST_THREAD; + return m_read_thread_enabled; } bool @@ -232,6 +232,7 @@ Communication::StopReadThread (Error *error_ptr) Host::ThreadCancel (m_read_thread, error_ptr); return Host::ThreadJoin (m_read_thread, NULL, error_ptr); + m_read_thread = LLDB_INVALID_HOST_THREAD; } @@ -339,7 +340,6 @@ Communication::ReadThread (void *p) log->Printf ("%p Communication::ReadThread () thread exiting...", p); // Let clients know that this thread is exiting - comm->m_read_thread = LLDB_INVALID_HOST_THREAD; comm->BroadcastEvent (eBroadcastBitReadThreadDidExit); return NULL; }