From 6af89b98f314436069132b2d5dc5594c67a90caa Mon Sep 17 00:00:00 2001 From: Thomas Bartelmess Date: Thu, 30 Aug 2018 18:49:18 +0200 Subject: [PATCH] Don't "connect" the UDP socket. Establishing a "connection" for UDP means that on Linux the underlying socket will deal with ICMP responses about undelivered packages. The connection gets marked as "closed" by the OS after an "unreachable" ICMP message for the source port arrives. From what I can tell there is not too much of a performance win for calling connect() execpt that every packet will have a different source port (at least on 18.04 Bionic Beaver). --- lib/gelf/transport/udp.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/gelf/transport/udp.rb b/lib/gelf/transport/udp.rb index 4f664e7..fbf23f0 100644 --- a/lib/gelf/transport/udp.rb +++ b/lib/gelf/transport/udp.rb @@ -31,12 +31,11 @@ def close def create_consumer_for host, port Thread.new do socket = UDPSocket.new(Addrinfo.ip(host).afamily) - socket.connect(host, port) loop do datagram = @q.pop break unless datagram - socket.send(datagram, 0) + socket.send(datagram, 0, host, port) end end end