mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
(maint) Use timeout builtin to TCPSocket when opening sockets.
This commit is contained in:
parent
8344f89722
commit
60fe266c9e
1 changed files with 9 additions and 11 deletions
|
|
@ -540,17 +540,15 @@ module Vmpooler
|
|||
},
|
||||
kind: :client
|
||||
) do
|
||||
Timeout.timeout(timeout) do
|
||||
target_host = host
|
||||
target_host = "#{host}.#{domain}" if domain
|
||||
span = OpenTelemetry::Trace.current_span
|
||||
span.set_attribute('net.peer.name', target_host)
|
||||
sock = TCPSocket.new target_host, port
|
||||
begin
|
||||
yield sock if block_given?
|
||||
ensure
|
||||
sock.close
|
||||
end
|
||||
target_host = host
|
||||
target_host = "#{host}.#{domain}" if domain
|
||||
span = OpenTelemetry::Trace.current_span
|
||||
span.set_attribute('net.peer.name', target_host)
|
||||
sock = TCPSocket.new(target_host, port, connect_timeout: timeout)
|
||||
begin
|
||||
yield sock if block_given?
|
||||
ensure
|
||||
sock.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue