(maint) Use timeout builtin to TCPSocket when opening sockets.

This commit is contained in:
isaac-hammes 2023-03-02 10:56:40 -08:00
parent 8344f89722
commit 60fe266c9e

View file

@ -540,17 +540,15 @@ module Vmpooler
}, },
kind: :client kind: :client
) do ) do
Timeout.timeout(timeout) do target_host = host
target_host = host target_host = "#{host}.#{domain}" if domain
target_host = "#{host}.#{domain}" if domain span = OpenTelemetry::Trace.current_span
span = OpenTelemetry::Trace.current_span span.set_attribute('net.peer.name', target_host)
span.set_attribute('net.peer.name', target_host) sock = TCPSocket.new(target_host, port, connect_timeout: timeout)
sock = TCPSocket.new target_host, port begin
begin yield sock if block_given?
yield sock if block_given? ensure
ensure sock.close
sock.close
end
end end
end end
end end