]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Treat clean shutdown of an SSL connection same as the non-SSL case.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 3 Jul 2017 11:51:51 +0000 (14:51 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 3 Jul 2017 11:53:08 +0000 (14:53 +0300)
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

src/backend/libpq/be-secure.c

index 8a435e28dfd28136d5bee7ec6edc55522dec2619..dc226f2fbca76b91383696d5bc8c92572b9d2eb8 100644 (file)
@@ -298,11 +298,13 @@ rloop:
                                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),
@@ -423,8 +425,14 @@ wloop:
                                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;