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