Skip to content

Commit df41577

Browse files
committed
Add comment about AI_ADDRCONFIG
1 parent a8a9b1d commit df41577

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/redis/connection/ruby.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ def self.connect_addrinfo(ai, port, timeout)
135135
end
136136

137137
def self.connect(host, port, timeout)
138+
# Don't pass AI_ADDRCONFIG as flag to getaddrinfo(3)
139+
#
140+
# From the man page for getaddrinfo(3):
141+
#
142+
# If hints.ai_flags includes the AI_ADDRCONFIG flag, then IPv4
143+
# addresses are returned in the list pointed to by res only if the
144+
# local system has at least one IPv4 address configured, and IPv6
145+
# addresses are returned only if the local system has at least one
146+
# IPv6 address configured. The loopback address is not considered
147+
# for this case as valid as a configured address.
148+
#
149+
# We do want the IPv6 loopback address to be returned if applicable,
150+
# even if it is the only configured IPv6 address on the machine.
151+
# Also see: https://github.com/redis/redis-rb/pull/394.
138152
addrinfo = ::Socket.getaddrinfo(host, nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM)
139153

140154
# From the man page for getaddrinfo(3):

0 commit comments

Comments
 (0)