Skip to content

Commit 90e86e9

Browse files
DrSergeigithub-actions[bot]
authored andcommitted
Automerge: [lldb-dap] Fix flaky test TestDAP_server (#145231)
This patch fixes a possible data race between main and event handler threads. Terminated event can be sent from `Disconnect` function or event handler. Consequently, there are some possible sequences of events. We must check events twice, because without getting an exited event, `exit_status` will be None. But, we don't know the order of events (for example, we can get terminated event before exited event), so we check events by filter. It is correct, because terminated event will be sent only once (guarded by `llvm::call_once`). This patch moved from [145010](llvm/llvm-project#145010) and based on idea from this [comment](llvm/llvm-project#145010 (comment)).
2 parents a920b33 + 5fe63ae commit 90e86e9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lldb/test/API/tools/lldb-dap/server/TestDAP_server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def test_server_interrupt(self):
101101
# Interrupt the server which should disconnect all clients.
102102
process.send_signal(signal.SIGINT)
103103

104-
self.dap_server.wait_for_terminated()
104+
# Wait for both events since they can happen in any order.
105+
self.dap_server.wait_for_event(["terminated", "exited"])
106+
self.dap_server.wait_for_event(["terminated", "exited"])
105107
self.assertIsNotNone(
106108
self.dap_server.exit_status,
107109
"Process exited before interrupting lldb-dap server",

lldb/tools/lldb-dap/tool/lldb-dap.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ serveConnection(const Socket::SocketProtocol &protocol, const std::string &name,
351351
<< " disconnected failed: "
352352
<< llvm::toString(std::move(error)) << "\n";
353353
}
354-
// Close the socket to ensure the DAP::Loop read finishes.
355-
sock->Close();
356354
}
357355
}
358356

0 commit comments

Comments
 (0)