Skip to content

Commit 543e00b

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 cc154d9 commit 543e00b

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
@@ -289,11 +289,13 @@ secure_read(Port *port, void *ptr, size_t len)
289289
ereport(COMMERROR,
290290
(errcode(ERRCODE_PROTOCOL_VIOLATION),
291291
errmsg("SSL error: %s", SSLerrmessage(ecode))));
292-
/* fall through */
293-
case SSL_ERROR_ZERO_RETURN:
294292
errno = ECONNRESET;
295293
n = -1;
296294
break;
295+
case SSL_ERROR_ZERO_RETURN:
296+
/* connection was cleanly shut down by peer */
297+
n = 0;
298+
break;
297299
default:
298300
ereport(COMMERROR,
299301
(errcode(ERRCODE_PROTOCOL_VIOLATION),
@@ -414,8 +416,14 @@ secure_write(Port *port, void *ptr, size_t len)
414416
ereport(COMMERROR,
415417
(errcode(ERRCODE_PROTOCOL_VIOLATION),
416418
errmsg("SSL error: %s", SSLerrmessage(ecode))));
417-
/* fall through */
419+
errno = ECONNRESET;
420+
n = -1;
421+
break;
418422
case SSL_ERROR_ZERO_RETURN:
423+
/*
424+
* the SSL connnection was closed, leave it to the caller
425+
* to ereport it
426+
*/
419427
errno = ECONNRESET;
420428
n = -1;
421429
break;

0 commit comments

Comments
 (0)