Skip to content

Commit

Permalink
Do not use HEAD request if 1 port
Browse files Browse the repository at this point in the history
If there is only one opening debug port with UNIX domain socket,
no need to use HEAD request.

Before:
```
$ exe/rdbg -O target.rb
DEBUGGER: Debugger can attach via UNIX domain socket (/run/user/1000/ruby-debug-ko1-223816)
DEBUGGER: wait for debugger connection...
DEBUGGER: Connected.
DEBUGGER: GreetingError: HEAD request
DEBUGGER: Disconnected.
DEBUGGER: Connected.
```

After:
```
$ exe/rdbg -O target.rb
DEBUGGER: Debugger can attach via UNIX domain socket (/run/user/1000/ruby-debug-ko1-223984)
DEBUGGER: wait for debugger connection...
DEBUGGER: Connected.
```
  • Loading branch information
ko1 committed Nov 14, 2023
1 parent 5b47f6a commit 0b0a49c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/debug/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,16 @@ def connect_unix name = nil
end
else
Client.cleanup_unix_domain_sockets
files = Client.list_connections verbose: true
files = Client.list_connections

case files.size
when 0
$stderr.puts "No debug session is available."
exit
when 1
@s = Socket.unix(files.first.first)
@s = Socket.unix(files.first)
else
files = Client.list_connections verbose: true
$stderr.puts "Please select a debug session:"
files.each{|(f, desc)|
$stderr.puts " #{File.basename(f)} (#{desc})"
Expand Down

0 comments on commit 0b0a49c

Please sign in to comment.