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

Commitd00391e

Browse files
committed
Sigh, I'm an idiot ... I broke the async startup logic a couple days ago,
by creating a race condition. It wasn't waiting for select() to saywrite-ready immediately after connect, which meant that you might getan unhelpful 'broken pipe' error message if connect failed, rather thanthe intended error message.
1 parentfdc85f5 commitd00391e

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.110 2000/01/15 05:37:21 ishii Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.111 2000/01/16 21:18:52 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -931,10 +931,16 @@ connectDBStart(PGconn *conn)
931931
staticint
932932
connectDBComplete(PGconn*conn)
933933
{
934-
PostgresPollingStatusTypeflag;
934+
PostgresPollingStatusTypeflag=PGRES_POLLING_WRITING;
935+
936+
if (conn==NULL||conn->status==CONNECTION_BAD)
937+
return0;
935938

936939
for (;;) {
937-
flag=PQconnectPoll(conn);
940+
/*
941+
* Wait, if necessary. Note that the initial state (just after
942+
* PQconnectStart) is to wait for the socket to select for writing.
943+
*/
938944
switch (flag)
939945
{
940946
casePGRES_POLLING_ACTIVE:
@@ -964,6 +970,10 @@ connectDBComplete(PGconn *conn)
964970
conn->status=CONNECTION_BAD;
965971
return0;
966972
}
973+
/*
974+
* Now try to advance the state machine.
975+
*/
976+
flag=PQconnectPoll(conn);
967977
}
968978
}
969979

@@ -1347,12 +1357,16 @@ PQconnectPoll(PGconn *conn)
13471357
* Starts the process of passing the values of a standard set of environment
13481358
* variables to the backend.
13491359
*
1350-
* ---------------- */
1360+
* ----------------
1361+
*/
13511362
PGsetenvHandle
13521363
PQsetenvStart(PGconn*conn)
13531364
{
13541365
structpg_setenv_state*handle;
13551366

1367+
if (conn==NULL||conn->status==CONNECTION_BAD)
1368+
returnNULL;
1369+
13561370
if ((handle=malloc(sizeof(structpg_setenv_state)))==NULL)
13571371
{
13581372
printfPQExpBuffer(&conn->errorMessage,
@@ -1621,13 +1635,16 @@ int
16211635
PQsetenv(PGconn*conn)
16221636
{
16231637
PGsetenvHandlehandle;
1624-
PostgresPollingStatusTypeflag;
1638+
PostgresPollingStatusTypeflag=PGRES_POLLING_WRITING;
16251639

16261640
if ((handle=PQsetenvStart(conn))==NULL)
16271641
return0;
16281642

16291643
for (;;) {
1630-
flag=PQsetenvPoll(conn);
1644+
/*
1645+
* Wait, if necessary. Note that the initial state (just after
1646+
* PQsetenvStart) is to wait for the socket to select for writing.
1647+
*/
16311648
switch (flag)
16321649
{
16331650
casePGRES_POLLING_ACTIVE:
@@ -1653,10 +1670,14 @@ PQsetenv(PGconn *conn)
16531670
break;
16541671

16551672
default:
1656-
/* Just in case we failed to set it inPQconnectPoll */
1673+
/* Just in case we failed to set it inPQsetenvPoll */
16571674
conn->status=CONNECTION_BAD;
16581675
return0;
16591676
}
1677+
/*
1678+
* Now try to advance the state machine.
1679+
*/
1680+
flag=PQsetenvPoll(conn);
16601681
}
16611682
}
16621683

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp