On Windows, close the client socket explicitly during backend shutdown.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 2 Dec 2021 22:14:43 +0000 (17:14 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 2 Dec 2021 22:15:05 +0000 (17:15 -0500)
commit3e644dcca1e97d7f4276dc2233c467addb179c88
tree0f1c66041f6674c4c842adac08b33e272c67b22d
parentb6e525648d723fb915c4bd376de62f4e28099189
On Windows, close the client socket explicitly during backend shutdown.

It turns out that this is necessary to keep Winsock from dropping any
not-yet-sent data, such as an error message explaining the reason for
process termination.  It's pretty weird that the implicit close done
by the kernel acts differently from an explicit close, but it's hard
to argue with experimental results.

Independently submitted by Alexander Lakhin and Lars Kanis (comments
by me, though).  Back-patch to all supported branches.

Discussion: https://postgr.es/m/90b34057-4176-7bb0-0dbb-9822a5f6425b@greiz-reinsdorf.de
Discussion: https://postgr.es/m/16678-253e48d34dc0c376@postgresql.org
src/backend/libpq/pqcomm.c