Skip to content

Commit

Permalink
out_forward: Fix to update timeout of cached sockets
Browse files Browse the repository at this point in the history
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 <ashie@clear-code.com>
  • Loading branch information
ashie committed Apr 11, 2022
1 parent b04e808 commit 527e7db
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/fluent/plugin/out_forward/socket_cache.rb
Expand Up @@ -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}")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 527e7db

Please sign in to comment.