aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-12-07 13:34:06 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2021-12-07 13:34:24 -0500
commita9e572c6d5761e8f9b726ba2b9d63a01186994f1 (patch)
tree519de956ad40df762141b4eab37ddab87358b6d0 /src
parent386d97781d1779ca76958bff193749082279182f (diff)
downloadpostgresql-a9e572c6d5761e8f9b726ba2b9d63a01186994f1.tar.gz
postgresql-a9e572c6d5761e8f9b726ba2b9d63a01186994f1.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/libpq/pqcomm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 53f45940563..d92c21646e2 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -296,7 +296,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
@@ -304,6 +305,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