Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBjM4-00C7YH-Bv for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Dec 2023 22:29:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rBjM2-00CGtB-K3 for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Dec 2023 22:29:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBjM2-00CGt2-9X for pgsql-hackers@lists.postgresql.org; Fri, 08 Dec 2023 22:29:54 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBjLw-00AtDR-TP for pgsql-hackers@postgresql.org; Fri, 08 Dec 2023 22:29:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3B8MTjfN1550647; Fri, 8 Dec 2023 17:29:45 -0500 From: Tom Lane To: Andres Freund cc: Peter Eisentraut , pgsql-hackers Subject: Re: backtrace_on_internal_error In-reply-to: <20231208193316.5ylgs4zb6zngwyg4@awork3.anarazel.de> References: <93f32d1a-9309-48dc-9b7f-c110c4d48126@eisentraut.org> <1266459.1701958930@sss.pgh.pa.us> <1439034.1702047909@sss.pgh.pa.us> <20231208181451.deqnflwxqoehhxpe@awork3.anarazel.de> <1466396.1702059830@sss.pgh.pa.us> <20231208183440.5z2rdpojcs5h5slk@awork3.anarazel.de> <1469753.1702061167@sss.pgh.pa.us> <20231208185101.x5z6vgkdtakqo4ny@awork3.anarazel.de> <20231208193316.5ylgs4zb6zngwyg4@awork3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Fri, 08 Dec 2023 11:33:16 -0800" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1550607.1702074562.0@sss.pgh.pa.us> Date: Fri, 08 Dec 2023 17:29:45 -0500 Message-ID: <1550646.1702074585@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1550607.1702074562.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Andres Freund writes: >> I think I figured it it out. Looks like we need to translate a closed s= ocket >> (recvfrom() returning 0) to ECONNRESET or such. > Seems like we should just treat errno =3D=3D 0 as a reason to emit the "= EOF > detected" message? Agreed. I think we want to do that after the initial handshake, too, so maybe as attached. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="handle-openssl-returning-errno-zero.patch"; charset="us-ascii" Content-ID: <1550607.1702074562.2@sss.pgh.pa.us> Content-Description: handle-openssl-returning-errno-zero.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-= secure-openssl.c index 6b8125695a..f0b35f08c6 100644 --- a/src/backend/libpq/be-secure-openssl.c +++ b/src/backend/libpq/be-secure-openssl.c @@ -460,6 +460,7 @@ aloop: * per-thread error queue following another call to an OpenSSL I/O * routine. */ + errno =3D 0; ERR_clear_error(); r =3D SSL_accept(port->ssl); if (r <=3D 0) @@ -496,7 +497,7 @@ aloop: WAIT_EVENT_SSL_OPEN_SERVER); goto aloop; case SSL_ERROR_SYSCALL: - if (r < 0) + if (r < 0 && errno !=3D 0) ereport(COMMERROR, (errcode_for_socket_access(), errmsg("could not accept SSL connection: %m"))); @@ -732,7 +733,7 @@ be_tls_read(Port *port, void *ptr, size_t len, int *wa= itfor) break; case SSL_ERROR_SYSCALL: /* leave it to caller to ereport the value of errno */ - if (n !=3D -1) + if (n !=3D -1 || errno =3D=3D 0) { errno =3D ECONNRESET; n =3D -1; ------- =_aaaaaaaaaa0--