Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49cd8a3

Browse files
committed
On further testing, PQping also needs an explicit check for AUTH_REQ.
The pg_fe_sendauth code might fail if it can't handle the authenticationrequest message type --- if so, ping should still say the server is up.
1 parentdb96e1c commit49cd8a3

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,6 +2321,8 @@ PQconnectPoll(PGconn *conn)
23212321
}
23222322

23232323
/* It is an authentication request. */
2324+
conn->auth_req_received= true;
2325+
23242326
/* Get the type of request. */
23252327
if (pqGetInt((int*)&areq,4,conn))
23262328
{
@@ -2589,11 +2591,18 @@ internal_ping(PGconn *conn)
25892591
returnPQPING_OK;
25902592

25912593
/*
2592-
* Hereis the interesting part of "ping": determine the cause of the
2594+
* Herebegins the interesting part of "ping": determine the cause of the
25932595
* failure in sufficient detail to decide what to return. We do not want
25942596
* to report that the server is not up just because we didn't have a valid
2595-
* password, for example.
2596-
*
2597+
* password, for example. In fact, any sort of authentication request
2598+
* implies the server is up. (We need this check since the libpq side
2599+
* of things might have pulled the plug on the connection before getting
2600+
* an error as such from the postmaster.)
2601+
*/
2602+
if (conn->auth_req_received)
2603+
returnPQPING_OK;
2604+
2605+
/*
25972606
* If we failed to get any ERROR response from the postmaster, report
25982607
* PQPING_NO_RESPONSE. This result could be somewhat misleading for a
25992608
* pre-7.4 server, since it won't send back a SQLSTATE, but those are long
@@ -2672,6 +2681,7 @@ makeEmptyPGconn(void)
26722681
conn->std_strings= false;/* unless server says differently */
26732682
conn->verbosity=PQERRORS_DEFAULT;
26742683
conn->sock=-1;
2684+
conn->auth_req_received= false;
26752685
conn->password_needed= false;
26762686
conn->dot_pgpass_used= false;
26772687
#ifdefUSE_SSL

‎src/interfaces/libpq/libpq-int.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ struct pg_conn
349349
SockAddrraddr;/* Remote address */
350350
ProtocolVersionpversion;/* FE/BE protocol version in use */
351351
intsversion;/* server version, e.g. 70401 for 7.4.1 */
352+
boolauth_req_received;/* true if any type of auth req received */
352353
boolpassword_needed;/* true if server demanded a password */
353354
booldot_pgpass_used;/* true if used .pgpass */
354355
boolsigpipe_so;/* have we masked SIGPIPE via SO_NOSIGPIPE? */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp