mirror of
https://github.com/postgres/postgres.git
synced 2025-06-19 04:21:08 +03:00
Reorder the asynchronous libpq calls for replication connection
Per libpq documentation, the initial state must be PGRES_POLLING_WRITING. Failing to do that appears to cause some issues on some Windows systems. From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
This commit is contained in:
@ -155,12 +155,16 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Poll connection. */
|
/*
|
||||||
do
|
* Poll connection until we have OK or FAILED status.
|
||||||
|
*
|
||||||
|
* Note that the initial state after PQconnectStartParams is
|
||||||
|
* PGRES_POLLING_WRITING.
|
||||||
|
*/
|
||||||
|
for (status = PGRES_POLLING_WRITING;
|
||||||
|
status != PGRES_POLLING_OK && status != PGRES_POLLING_FAILED;
|
||||||
|
status = PQconnectPoll(conn->streamConn))
|
||||||
{
|
{
|
||||||
/* Determine current state of the connection. */
|
|
||||||
status = PQconnectPoll(conn->streamConn);
|
|
||||||
|
|
||||||
/* Sleep a bit if waiting for socket. */
|
/* Sleep a bit if waiting for socket. */
|
||||||
if (status == PGRES_POLLING_READING ||
|
if (status == PGRES_POLLING_READING ||
|
||||||
status == PGRES_POLLING_WRITING)
|
status == PGRES_POLLING_WRITING)
|
||||||
@ -188,9 +192,7 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
|
|||||||
if (rc & WL_LATCH_SET)
|
if (rc & WL_LATCH_SET)
|
||||||
CHECK_FOR_INTERRUPTS();
|
CHECK_FOR_INTERRUPTS();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Otherwise loop until we have OK or FAILED status. */
|
|
||||||
} while (status != PGRES_POLLING_OK && status != PGRES_POLLING_FAILED);
|
|
||||||
|
|
||||||
if (PQstatus(conn->streamConn) != CONNECTION_OK)
|
if (PQstatus(conn->streamConn) != CONNECTION_OK)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user