Skip to content

Commit 76975c7

Browse files
committed
Revert "[lldb/Core] Fix a race in the Communication class"
This reverts commit ebb0713 -- it seems to introduce a deadlock in some circumstances.
1 parent a7efe06 commit 76975c7

File tree

3 files changed

+9
-48
lines changed

3 files changed

+9
-48
lines changed

lldb/source/Core/Communication.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,25 +315,28 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
315315
Status error;
316316
ConnectionStatus status = eConnectionStatusSuccess;
317317
bool done = false;
318-
bool disconnect = false;
319318
while (!done && comm->m_read_thread_enabled) {
320319
size_t bytes_read = comm->ReadFromConnection(
321320
buf, sizeof(buf), std::chrono::seconds(5), status, &error);
322-
if (bytes_read > 0 || status == eConnectionStatusEndOfFile)
321+
if (bytes_read > 0)
323322
comm->AppendBytesToCache(buf, bytes_read, true, status);
323+
else if ((bytes_read == 0) && status == eConnectionStatusEndOfFile) {
324+
if (comm->GetCloseOnEOF())
325+
comm->Disconnect();
326+
comm->AppendBytesToCache(buf, bytes_read, true, status);
327+
}
324328

325329
switch (status) {
326330
case eConnectionStatusSuccess:
327331
break;
328332

329333
case eConnectionStatusEndOfFile:
330334
done = true;
331-
disconnect = comm->GetCloseOnEOF();
332335
break;
333336
case eConnectionStatusError: // Check GetError() for details
334337
if (error.GetType() == eErrorTypePOSIX && error.GetError() == EIO) {
335338
// EIO on a pipe is usually caused by remote shutdown
336-
disconnect = comm->GetCloseOnEOF();
339+
comm->Disconnect();
337340
done = true;
338341
}
339342
if (error.Fail())
@@ -362,15 +365,9 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
362365
if (log)
363366
LLDB_LOGF(log, "%p Communication::ReadThread () thread exiting...", p);
364367

365-
comm->BroadcastEvent(eBroadcastBitNoMorePendingInput);
366-
{
367-
std::lock_guard<std::mutex> guard(comm->m_synchronize_mutex);
368-
comm->m_read_thread_did_exit = true;
369-
if (disconnect)
370-
comm->Disconnect();
371-
}
372-
368+
comm->m_read_thread_did_exit = true;
373369
// Let clients know that this thread is exiting
370+
comm->BroadcastEvent(eBroadcastBitNoMorePendingInput);
374371
comm->BroadcastEvent(eBroadcastBitReadThreadDidExit);
375372
return {};
376373
}

lldb/unittests/Core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
add_lldb_unittest(LLDBCoreTests
2-
CommunicationTest.cpp
32
MangledTest.cpp
43
RichManglingContextTest.cpp
54
StreamCallbackTest.cpp

lldb/unittests/Core/CommunicationTest.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)