[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

Adrian Vogelsgesang via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 15 10:04:48 PST 2024


================
@@ -250,6 +251,13 @@ def which(program):
     return None
 
 
+def pickrandomport():
+    """Returns a random open port."""
+    with socket.socket() as sock:
+        sock.bind(("", 0))
+        return sock.getsockname()[1]
----------------
vogelsgesang wrote:

afaict, this will lead to a race condition? The `return` will exit the `with` scope, and we will give up the lock on the port number again?

https://github.com/llvm/llvm-project/pull/116392


More information about the lldb-commits mailing list