Re: MSVC SSL test failure

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Lars Kanis <lars(at)greiz-reinsdorf(dot)de>
Subject: Re: MSVC SSL test failure
Date: 2021-12-06 20:51:16
Message-ID: ba1b78e6-3777-58ae-4981-110bcf71e985@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 12/6/21 10:30, Alexander Lakhin wrote:
> Hello Andrew,
> 06.12.2021 17:56, Andrew Dunstan wrote:
>> Yeah, quite annoying, especially because only some combinations of MSVC
>> runtime / openssl version seem to trigger the problem.
>>
>>
>> Adding a shutdown() before the closesocket() also fixes the issue.
>>
> Can you confirm that adding shutdown(MyProcPort->sock, SD_BOTH) fixes
> the issue for many test runs?
> I don't see the stable test passing here.
> Without shutdown() the test failed on iterations 1, 5, 4, but with
> shutdown() it failed too, on iterations 3, 1, 4.
> Without close() and shutdown() the test passes 20 iterations.
> (I'm still researching how openssl affects the shutdown sequence.)

I have been getting 100% failures on the SSL tests with closesocket()
alone, and 100% success over 10 tests with this:

diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 96ab37c7d0..5998c089b0 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -295,6 +295,7 @@ socket_close(int code, Datum arg)
         * Windows too.  But it's a lot more fragile than the other way.
         */
 #ifdef WIN32
+       shutdown(MyProcPort->sock, SD_SEND);
        closesocket(MyProcPort->sock);
 #endif

That said, your results are quite worrying.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-12-06 21:05:32 Re: ExecTypeSetColNames is fundamentally broken
Previous Message Jacob Champion 2021-12-06 20:44:54 Re: Transparent column encryption