diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-10-22 18:41:54 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-10-22 18:41:54 -0400 |
commit | 6fa31d8d121df19d4625397bec607171a2afede5 (patch) | |
tree | 898a5f650b13efd883d814b903b4d268f5e2c87f /src | |
parent | fd29810d16fb81fc4a64ba78c80330e6d95b1dc5 (diff) |
Ensure libpq reports a suitable error message on unexpected socket EOF.
The EOF-detection logic in pqReadData was a bit confused about who should
set up the error message in case the kernel gives us read-ready-but-no-data
rather than ECONNRESET or some other explicit error condition. Since the
whole point of this situation is that the lower-level functions don't know
there's anything wrong, pqReadData itself must set up the message. But
keep the assumption that if an errno was reported, a message was set up at
lower levels.
Per bug #11712 from Marko Tiikkaja. It's been like this for a very long
time, so back-patch to all supported branches.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/libpq/fe-misc.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 1575675ad94..05655c70645 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -764,12 +764,8 @@ retry3: /* ready for read */ break; default: - printfPQExpBuffer(&conn->errorMessage, - libpq_gettext( - "server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); - goto definitelyFailed; + /* we override pqReadReady's message with something more useful */ + goto definitelyEOF; } /* @@ -808,9 +804,16 @@ retry4: /* * OK, we are getting a zero read even though select() says ready. This - * means the connection has been closed. Cope. Note that errorMessage - * has been set already. + * means the connection has been closed. Cope. */ +definitelyEOF: + printfPQExpBuffer(&conn->errorMessage, + libpq_gettext( + "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request.\n")); + + /* Come here if lower-level code already set a suitable errorMessage */ definitelyFailed: conn->status = CONNECTION_BAD; /* No more connection to backend */ pqsecure_close(conn); |