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

Commitac6e875

Browse files
committed
Ensure libpq reports a suitable error message on unexpected socket EOF.
The EOF-detection logic in pqReadData was a bit confused about who shouldset up the error message in case the kernel gives us read-ready-but-no-datarather than ECONNRESET or some other explicit error condition. Since thewhole point of this situation is that the lower-level functions don't knowthere's anything wrong, pqReadData itself must set up the message. Butkeep the assumption that if an errno was reported, a message was set up atlower levels.Per bug #11712 from Marko Tiikkaja. It's been like this for a very longtime, so back-patch to all supported branches.
1 parent98170fa commitac6e875

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,12 +730,8 @@ pqReadData(PGconn *conn)
730730
/* ready for read */
731731
break;
732732
default:
733-
printfPQExpBuffer(&conn->errorMessage,
734-
libpq_gettext(
735-
"server closed the connection unexpectedly\n"
736-
"\tThis probably means the server terminated abnormally\n"
737-
"\tbefore or while processing the request.\n"));
738-
gotodefinitelyFailed;
733+
/* we override pqReadReady's message with something more useful */
734+
gotodefinitelyEOF;
739735
}
740736

741737
/*
@@ -774,9 +770,16 @@ pqReadData(PGconn *conn)
774770

775771
/*
776772
* OK, we are getting a zero read even though select() says ready. This
777-
* means the connection has been closed. Cope. Note that errorMessage
778-
* has been set already.
773+
* means the connection has been closed. Cope.
779774
*/
775+
definitelyEOF:
776+
printfPQExpBuffer(&conn->errorMessage,
777+
libpq_gettext(
778+
"server closed the connection unexpectedly\n"
779+
"\tThis probably means the server terminated abnormally\n"
780+
"\tbefore or while processing the request.\n"));
781+
782+
/* Come here if lower-level code already set a suitable errorMessage */
780783
definitelyFailed:
781784
conn->status=CONNECTION_BAD;/* No more connection to backend */
782785
pqsecure_close(conn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp