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

Commitb496645

Browse files
committed
Do not return from PQrequestCancel until postmaster has finished
processing the request; this ensures that the request won't be takento cancel a subsequently-issued query. Race condition originallynoted by Oliver Jowett in the context of JDBC, but libpq has it too.
1 parentbf2f5d9 commitb496645

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.261 2003/09/22 00:23:35 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.262 2003/10/02 19:52:44 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2262,7 +2262,23 @@ PQrequestCancel(PGconn *conn)
22622262
gotocancel_errReturn;
22632263
}
22642264

2265-
/* Sent it, done */
2265+
/*
2266+
* Wait for the postmaster to close the connection, which indicates that
2267+
* it's processed the request. Without this delay, we might issue another
2268+
* command only to find that our cancel zaps that command instead of the
2269+
* one we thought we were canceling. Note we don't actually expect this
2270+
* read to obtain any data, we are just waiting for EOF to be signaled.
2271+
*/
2272+
retry5:
2273+
if (recv(tmpsock, (char*)&crp,1,0)<0)
2274+
{
2275+
if (SOCK_ERRNO==EINTR)
2276+
/* Interrupted system call - we'll just try again */
2277+
gotoretry5;
2278+
/* we ignore other error conditions */
2279+
}
2280+
2281+
/* All done */
22662282
closesocket(tmpsock);
22672283
#ifdefWIN32
22682284
WSASetLastError(save_errno);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp