Skip to content

Commit fb63a0a

Browse files
committed
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
1 parent 5aa8db0 commit fb63a0a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/backend/libpq/be-secure.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,13 @@ secure_read(Port *port, void *ptr, size_t len)
298298
ereport(COMMERROR,
299299
(errcode(ERRCODE_PROTOCOL_VIOLATION),
300300
errmsg("SSL error: %s", SSLerrmessage(ecode))));
301-
/* fall through */
302-
case SSL_ERROR_ZERO_RETURN:
303301
errno = ECONNRESET;
304302
n = -1;
305303
break;
304+
case SSL_ERROR_ZERO_RETURN:
305+
/* connection was cleanly shut down by peer */
306+
n = 0;
307+
break;
306308
default:
307309
ereport(COMMERROR,
308310
(errcode(ERRCODE_PROTOCOL_VIOLATION),
@@ -423,8 +425,14 @@ secure_write(Port *port, void *ptr, size_t len)
423425
ereport(COMMERROR,
424426
(errcode(ERRCODE_PROTOCOL_VIOLATION),
425427
errmsg("SSL error: %s", SSLerrmessage(ecode))));
426-
/* fall through */
428+
errno = ECONNRESET;
429+
n = -1;
430+
break;
427431
case SSL_ERROR_ZERO_RETURN:
432+
/*
433+
* the SSL connnection was closed, leave it to the caller
434+
* to ereport it
435+
*/
428436
errno = ECONNRESET;
429437
n = -1;
430438
break;

0 commit comments

Comments
 (0)