diff --git a/lib/pg/connection.rb b/lib/pg/connection.rb index 196a19d51..a326c8778 100644 --- a/lib/pg/connection.rb +++ b/lib/pg/connection.rb @@ -653,8 +653,6 @@ def cancel # Track the progress of the connection, waiting for the socket to become readable/writable before polling it if (timeo = conninfo_hash[:connect_timeout].to_i) && timeo > 0 - # Lowest timeout is 2 seconds - like in libpq - timeo = [timeo, 2].max host_count = conninfo_hash[:host].to_s.count(",") + 1 stop_time = timeo * host_count + Process.clock_gettime(Process::CLOCK_MONOTONIC) end diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb index df5438ab3..a4bfd79ad 100644 --- a/spec/pg/connection_spec.rb +++ b/spec/pg/connection_spec.rb @@ -377,7 +377,7 @@ end end - expect( Time.now - start_time ).to be_between(1.9, 10).inclusive + expect( Time.now - start_time ).to be_between(0.9, 10).inclusive end end