From 713a4a2c9d5f304b43a626020d139d4596018726 Mon Sep 17 00:00:00 2001 From: isaac-hammes Date: Thu, 2 Mar 2023 11:27:55 -0800 Subject: [PATCH] (maint) Use timeout builtin to TCPSocket when opening sockets. --- lib/vmpooler/providers/vsphere.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/vmpooler/providers/vsphere.rb b/lib/vmpooler/providers/vsphere.rb index c572d48..e76e972 100644 --- a/lib/vmpooler/providers/vsphere.rb +++ b/lib/vmpooler/providers/vsphere.rb @@ -632,15 +632,13 @@ module Vmpooler # This should supercede the open_socket method in the Pool Manager def open_socket(host, domain = nil, timeout = 5, port = 22, &_block) - Timeout.timeout(timeout) do - target_host = host - target_host = "#{host}.#{domain}" if domain - 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 + sock = TCPSocket.new(target_host, port, connect_timeout: timeout) + begin + yield sock if block_given? + ensure + sock.close end end