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%3DvrvF2gxoZAMJLAPq3S3KkjhZAYi7aw@mail.gmail.com
This commit is contained in:
Heikki Linnakangas 2017-07-03 14:51:51 +03:00
parent bf723a274c
commit b93827c745
1 changed files with 11 additions and 3 deletions

View File

@ -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;