summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas2017-07-03 11:51:51 +0000
committerHeikki Linnakangas2017-07-03 11:51:51 +0000
commitb93827c745f346a765e7e59584127e07a37c78da (patch)
treebc7f46361d16952ae2b70d9267482647cfe9ee24
parentbf723a274cbb00c7fba66c66312a77940af13d79 (diff)
Treat clean shutdown of an SSL connection same as the non-SSL case.
If the client closes an SSL connection, treat it the same as EOF on a non-SSL connection. In particular, don't write a message in the log about that. Michael Paquier. Discussion: https://www.postgresql.org/message-id/CAB7nPqSfyVV42Q2acFo%[email protected]
-rw-r--r--src/backend/libpq/be-secure-openssl.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
index 036d58a24e..67145e9412 100644
--- a/src/backend/libpq/be-secure-openssl.c
+++ b/src/backend/libpq/be-secure-openssl.c
@@ -688,11 +688,13 @@ be_tls_read(Port *port, void *ptr, size_t len, int *waitfor)
ereport(COMMERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("SSL error: %s", SSLerrmessage(ecode))));
- /* fall through */
- case SSL_ERROR_ZERO_RETURN:
errno = ECONNRESET;
n = -1;
break;
+ case SSL_ERROR_ZERO_RETURN:
+ /* connection was cleanly shut down by peer */
+ n = 0;
+ break;
default:
ereport(COMMERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
@@ -748,8 +750,14 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
ereport(COMMERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("SSL error: %s", SSLerrmessage(ecode))));
- /* fall through */
+ errno = ECONNRESET;
+ n = -1;
+ break;
case SSL_ERROR_ZERO_RETURN:
+ /*
+ * the SSL connnection was closed, leave it to the caller
+ * to ereport it
+ */
errno = ECONNRESET;
n = -1;
break;