Skip to content

Commit 0ef30e1

Browse files
committed
rabbit_networking: Take IP address from #listener{} instead of guessing
[Why] Some systems use explicit distinct listeners for IPv4 and IPv6 (for instance, FreeBSD). Other system will listen to IPv4 implicitly when listening on IPv6 (for instance, Linux). RabbitMQ works on both systems already, but `ranch_ref/1` was trying to guess the IP address of a given listener based on its TCP port. Of course, for two distinct listeners using the same TCP port, the result was always the same IP address. [How] The #listener{} record already contains the IP address. Let's just use it, instead of guessing.
1 parent 6515471 commit 0ef30e1

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

deps/rabbit/src/rabbit_networking.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ tcp_listener_spec(NamePrefix, {IPAddress, Port, Family}, SocketOpts,
197197
transient, infinity, supervisor, [tcp_listener_sup]}.
198198

199199
-spec ranch_ref(#listener{} | [{atom(), any()}] | 'undefined') -> ranch:ref() | undefined.
200-
ranch_ref(#listener{port = Port}) ->
201-
[{IPAddress, Port, _Family} | _] = tcp_listener_addresses(Port),
200+
ranch_ref(#listener{ip_address = IPAddress, port = Port}) ->
202201
{acceptor, IPAddress, Port};
203202
ranch_ref(Listener) when is_list(Listener) ->
204203
Port = rabbit_misc:pget(port, Listener),

0 commit comments

Comments
 (0)