Skip to content

Commit 68ac787

Browse files
committed
Merge branch 'check_connection'
2 parents 2e663b3 + 77cc9e6 commit 68ac787

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

History.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Enhancements:
3030
Previously stdlib libraries `date`, `json`, `ipaddr` and `bigdecimal` were static dependencies, but now only `socket` is mandatory.
3131
- Improve garbage collector performance by adding write barriers to all PG classes. [#518](https://github.com/ged/ruby-pg/pull/518)
3232
Now they can be promoted to the old generation, which means they only get marked on major GC.
33-
- New method PG::Connection#check_connection to check the socket state. [#521](https://github.com/ged/ruby-pg/pull/521)
33+
- New method PG::Connection#check_socket to check the socket state. [#521](https://github.com/ged/ruby-pg/pull/521)
3434
- Update Windows fat binary gem to OpenSSL-3.1.0.
3535

3636
Bugfixes:

ext/pg_connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ pgconn_conninfo( VALUE self )
765765
*
766766
* This method returns the status of the last command from memory.
767767
* It doesn't do any socket access hence is not suitable to test the connectivity.
768-
* See check_connection for a way to verify the socket state.
768+
* See check_socket for a way to verify the socket state.
769769
*
770770
* Example:
771771
* PG.constants.grep(/CONNECTION_/).find{|c| PG.const_get(c) == conn.status} # => :CONNECTION_OK

lib/pg/connection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def ssl_attributes
353353
#
354354
# The method doesn't verify that the server is still responding.
355355
# To verify that the communication to the server works, it is recommended to use something like <tt>conn.exec('')</tt> instead.
356-
def check_connection
356+
def check_socket
357357
while socket_io.wait_readable(0)
358358
consume_input
359359
end
@@ -831,7 +831,7 @@ def new(*args)
831831
# [+PQPING_NO_ATTEMPT+]
832832
# connection not attempted (bad params)
833833
#
834-
# See also check_connection for a way to check the connection without doing any server communication.
834+
# See also check_socket for a way to check the connection without doing any server communication.
835835
def ping(*args)
836836
if Fiber.respond_to?(:scheduler) && Fiber.scheduler
837837
# Run PQping in a second thread to avoid blocking of the scheduler.

spec/pg/connection_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,15 +1678,15 @@
16781678
expect{ conn.consume_input }.to raise_error(PG::ConnectionBad, /can't get socket descriptor|connection not open/){|err| expect(err).to have_attributes(connection: conn) }
16791679
end
16801680

1681-
describe :check_connection do
1681+
describe :check_socket do
16821682
it "does nothing if connection is OK" do
1683-
expect( @conn.check_connection ).to be_nil
1683+
expect( @conn.check_socket ).to be_nil
16841684
end
16851685

1686-
def wait_check_connection(conn)
1686+
def wait_check_socket(conn)
16871687
retries = 100
16881688
loop do
1689-
conn.check_connection
1689+
conn.check_socket
16901690
sleep 0.1
16911691
break if (retries-=1) < 0
16921692
end
@@ -1698,7 +1698,7 @@ def wait_check_connection(conn)
16981698
expect( conn.get_result.result_status ).to be( PG::PGRES_FATAL_ERROR )
16991699

17001700
expect do
1701-
wait_check_connection(conn)
1701+
wait_check_socket(conn)
17021702
end.to raise_error(PG::ConnectionBad, /SSL connection has been closed unexpectedly|server closed the connection unexpectedly/)
17031703
end
17041704

@@ -1707,7 +1707,7 @@ def wait_check_connection(conn)
17071707
conn.send_query "do $$ BEGIN RAISE NOTICE 'foo'; PERFORM pg_terminate_backend(pg_backend_pid()); END; $$ LANGUAGE plpgsql;"
17081708

17091709
expect do
1710-
wait_check_connection(conn)
1710+
wait_check_socket(conn)
17111711
end.to raise_error(PG::ConnectionBad, /SSL connection has been closed unexpectedly|server closed the connection unexpectedly/)
17121712
end
17131713
end

0 commit comments

Comments
 (0)