aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-03-22 10:19:15 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-03-22 10:19:15 -0400
commit29992a6a509b256efc4ac560a1586b51a64b2637 (patch)
tree4d8d9632a0e711015c6b58cf3fbe2cf87c030671 /src
parent7faa5fc84bf46ea6c543993cffb8be64dff60d25 (diff)
downloadpostgresql-29992a6a509b256efc4ac560a1586b51a64b2637.tar.gz
postgresql-29992a6a509b256efc4ac560a1586b51a64b2637.zip
Revert "graceful shutdown" changes for Windows.
This reverts commits 6051857fc and ed52c3707 in HEAD (they were already reverted in the back branches). Further testing has shown that while those changes do fix some things, they also break others; in particular, it looks like walreceivers fail to detect walsender-initiated connection close reliably if the walsender shuts down this way. A proper fix for this seems possible but won't be done in time for v15. Discussion: https://postgr.es/m/CA+hUKG+OeoETZQ=Qw5Ub5h3tmwQhBmDA=nuNO3KG=zWfUypFAw@mail.gmail.com Discussion: https://postgr.es/m/CA+hUKGKkp2XkvSe9nG+bsgkXVKCdTeGSa_TR0Qx1jafc_oqCVA@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/libpq/pqcomm.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 47923b9e9de..7d3dc2a51f3 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -277,30 +277,15 @@ socket_close(int code, Datum arg)
secure_close(MyProcPort);
/*
- * On most platforms, we leave the socket open until the process dies.
- * This allows clients to perform a "synchronous close" if they care
- * --- wait till the transport layer reports connection closure, and
- * you can be sure the backend has exited. Saves a kernel call, too.
+ * Formerly we did an explicit close() here, but it seems better to
+ * leave the socket open until the process dies. This allows clients
+ * to perform a "synchronous close" if they care --- wait till the
+ * transport layer reports connection closure, and you can be sure the
+ * backend has exited.
*
- * However, that does not work on Windows: if the kernel closes the
- * socket it will invoke an "abortive shutdown" that discards any data
- * 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. 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
- * in principle it's good enough to act as a synchronous close on
- * Windows too. But it's a lot more fragile than the other way.
+ * We do set sock to PGINVALID_SOCKET to prevent any further I/O,
+ * though.
*/
-#ifdef WIN32
- shutdown(MyProcPort->sock, SD_SEND);
- closesocket(MyProcPort->sock);
-#endif
-
- /* In any case, set sock to PGINVALID_SOCKET to prevent further I/O */
MyProcPort->sock = PGINVALID_SOCKET;
}
}