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

Commitbb42ad1

Browse files
committed
Ensure we discard unread/unsent data when abandoning a connection attempt.
There are assorted situations wherein PQconnectPoll() will abandon aconnection attempt and try again with different parameters (eg, SSL versusnot SSL). However, the code forgot to discard any pending data in libpq'sI/O buffers when doing this. In at least one case (server returns Emessage during SSL negotiation), there is unread input data which bollixesthe next connection attempt. I have not checked to see whether this ispossible in the other cases where we close the socket and retry, but itseems like a matter of good defensive programming to add explicitbuffer-flushing code to all of them.This is one of several issues exposed by Daniel Farina's report ofmisbehavior after a server-side fork failure.This has been wrong since forever, so back-patch to all supported branches.
1 parentae42744 commitbb42ad1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,9 @@ PQconnectPoll(PGconn *conn)
13791379
closesocket(conn->sock);
13801380
conn->sock=-1;
13811381
conn->status=CONNECTION_NEEDED;
1382+
/* Discard any unread/unsent data */
1383+
conn->inStart=conn->inCursor=conn->inEnd=0;
1384+
conn->outCount=0;
13821385
gotokeep_going;
13831386
}
13841387
else
@@ -1416,6 +1419,9 @@ PQconnectPoll(PGconn *conn)
14161419
closesocket(conn->sock);
14171420
conn->sock=-1;
14181421
conn->status=CONNECTION_NEEDED;
1422+
/* Discard any unread/unsent data */
1423+
conn->inStart=conn->inCursor=conn->inEnd=0;
1424+
conn->outCount=0;
14191425
gotokeep_going;
14201426
}
14211427
}
@@ -1528,6 +1534,9 @@ PQconnectPoll(PGconn *conn)
15281534
closesocket(conn->sock);
15291535
conn->sock=-1;
15301536
conn->status=CONNECTION_NEEDED;
1537+
/* Discard any unread/unsent data */
1538+
conn->inStart=conn->inCursor=conn->inEnd=0;
1539+
conn->outCount=0;
15311540
gotokeep_going;
15321541
}
15331542

@@ -1594,6 +1603,9 @@ PQconnectPoll(PGconn *conn)
15941603
closesocket(conn->sock);
15951604
conn->sock=-1;
15961605
conn->status=CONNECTION_NEEDED;
1606+
/* Discard any unread/unsent data */
1607+
conn->inStart=conn->inCursor=conn->inEnd=0;
1608+
conn->outCount=0;
15971609
gotokeep_going;
15981610
}
15991611

@@ -1613,6 +1625,9 @@ PQconnectPoll(PGconn *conn)
16131625
closesocket(conn->sock);
16141626
conn->sock=-1;
16151627
conn->status=CONNECTION_NEEDED;
1628+
/* Discard any unread/unsent data */
1629+
conn->inStart=conn->inCursor=conn->inEnd=0;
1630+
conn->outCount=0;
16161631
gotokeep_going;
16171632
}
16181633
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp