postgres.git / summary / log / commit / refs
commit 23bc57d564b2dedb8b1d823a4fc71774afd9ff94
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue Dec 07 18:34:06 2021 +0000
First released in: master (reverted before release), REL_10_STABLE (reverted before release), REL_11_STABLE (reverted before release), REL_12_STABLE (reverted before release), REL_13_STABLE (reverted before release), REL_14_STABLE (reverted before release)
Reverted by: 645c9457f296 (in 10.20), bbb1caf6b220 (in 11.15), 64b2c6507e57 (in 12.10), 213c5aa3bdba (in 13.6), 75674c7ec1b1 (in 14.2), 29992a6a509b (in 15.0)
On Windows, also call shutdown() while closing the client socket.
Further experimentation shows that commit 6051857fc is not sufficient
when using (some versions of?) OpenSSL. The reason is obscure, but
calling shutdown(socket, SD_SEND) improves matters.
Per testing by Andrew Dunstan and Alexander Lakhin.
Back-patch as before.
Discussion: https://postgr.es/m/af5e0bf3-6a61-bb97-6cba-061ddf22ff6b@dunslane.net
src/backend/libpq/pqcomm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 889107ab755..219a17cf116 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -299,7 +299,8 @@ socket_close(int code, Datum arg)
* not yet sent to the client. (This is a flat-out violation of the
* TCP RFCs, but count on Microsoft not to care about that.) To get
* the spec-compliant "graceful shutdown" behavior, we must invoke
- * closesocket() explicitly.
+ * closesocket() explicitly. When using OpenSSL, it seems that clean
+ * shutdown also requires an explicit shutdown() call.
*
* This code runs late enough during process shutdown that we should
* have finished all externally-visible shutdown activities, so that
@@ -307,6 +308,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
[parent: 7b0643c77b46]