From 3a435b2eabfa1f307895fa3e00fc46368498f75a Mon Sep 17 00:00:00 2001 From: anjiahao Date: Thu, 25 Jan 2024 17:19:49 +0800 Subject: [PATCH] minidumpserver.py:avoid port already used Signed-off-by: anjiahao --- tools/minidumpserver.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/minidumpserver.py b/tools/minidumpserver.py index 99e0e30fa8..db89a07cef 100755 --- a/tools/minidumpserver.py +++ b/tools/minidumpserver.py @@ -779,7 +779,15 @@ def main(args): # close before we can bind to the port again gdbserver.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - gdbserver.bind(("", args.port)) + try: + gdbserver.bind(("", args.port)) + except OSError: + gdbserver.bind(("", 0)) + logger.info( + f"Port {args.port} is already in use, using port {gdbserver.getsockname()[1]} instead." + ) + args.port = gdbserver.getsockname()[1] + gdbserver.listen(1) gdb_exec = "gdb" if not args.gdb else args.gdb