Skip to content

Commit

Permalink
server: Fix IPv6 dual stack mode issue for udp socket. fix #2768
Browse files Browse the repository at this point in the history
Signed-off-by: Masahiro Nakagawa <[email protected]>
  • Loading branch information
repeatedly committed Jan 17, 2020
1 parent a353793 commit 5f80f5b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/fluent/plugin_helper/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,9 @@ def server_create_udp_socket(shared, bind, port)
sock = if shared
server_socket_manager_client.listen_udp(bind, port)
else
family = IPAddr.new(IPSocket.getaddress(bind)).ipv4? ? ::Socket::AF_INET : ::Socket::AF_INET6
usock = UDPSocket.new(family)
usock.bind(bind, port)
usock
usock = Addrinfo.udp(bind, port).bind
usock.autoclose = false
UDPSocket.for_fd(usock.fileno)
end
# close-on-exec is set by default in Ruby 2.0 or later (, and it's unavailable on Windows)
sock.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK) # nonblock
Expand Down

0 comments on commit 5f80f5b

Please sign in to comment.