From 527e7dbfc643ceb8c0b7385095abf677ff8772d6 Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Mon, 11 Apr 2022 16:34:11 +0900 Subject: [PATCH] out_forward: Fix to update timeout of cached sockets In `SocketCache`, timeout of sockets are set only on creating them and never be updated. So that cached sockets (`@available_sockets`) are always closed after `keepalive_timeout` is passed from its creation, even if it was used within `keepalive_timeout` seconds. Signed-off-by: Takuro Ashie --- lib/fluent/plugin/out_forward/socket_cache.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/fluent/plugin/out_forward/socket_cache.rb b/lib/fluent/plugin/out_forward/socket_cache.rb index 525988e9b3..925eef0fad 100644 --- a/lib/fluent/plugin/out_forward/socket_cache.rb +++ b/lib/fluent/plugin/out_forward/socket_cache.rb @@ -50,6 +50,7 @@ def checkout_or(key) def checkin(sock) @mutex.synchronize do if (s = @inflight_sockets.delete(sock)) + s.timeout = timeout @available_sockets[s.key] << s else @log.debug("there is no socket #{sock}") @@ -122,6 +123,7 @@ def pick_socket(key) t = Time.now if (s = @available_sockets[key].find { |sock| !expired_socket?(sock, time: t) }) @inflight_sockets[s.sock] = @available_sockets[key].delete(s) + s.timeout = timeout s else nil