From 88ee48cacff8988e36502c4c63d0a99d044a794d Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Wed, 14 Feb 2024 10:18:59 -0800 Subject: [PATCH] Fix openssl error handling, #83 --- lib/faktory/client.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/faktory/client.rb b/lib/faktory/client.rb index d309569..7c4cedd 100644 --- a/lib/faktory/client.rb +++ b/lib/faktory/client.rb @@ -56,6 +56,12 @@ def initialize(url: uri_from_env || "tcp://localhost:7419", debug: false, timeou @debug = debug @location = URI(url) @timeout = timeout + @errors = [SystemCallError, SocketError, TimeoutError] + + if tls? + require "openssl" + @errors << OpenSSL::SSL::SSLError + end open_socket(@timeout) end @@ -251,7 +257,6 @@ def tls? # NB: aliased by faktory/testing def open_socket(timeout = DEFAULT_TIMEOUT) if tls? - require "openssl" sock = TCPSocket.new(@location.hostname, @location.port) sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true) @@ -321,7 +326,7 @@ def transaction begin yield - rescue SystemCallError, SocketError, TimeoutError, OpenSSL::SSL::SSLError + rescue *@errors if retryable retryable = false