Alexander Lakhin <exclusion@gmail.com> writes:
> 29.11.2021 22:16, Tom Lane wrote:
>> After re-reading that thread and re-studying relevant Windows
>> documentation [1][2], I think the main open question is whether
>> we need to issue shutdown() or not, and if so, whether to use
>> SD_BOTH or just SD_SEND. I'm inclined to prefer not calling
>> shutdown(), because [1] is self-contradictory as to whether it
>> can block, and [2] is pretty explicit that it's not necessary.
> I've tested the close-only patch with pg_sleep() in pqReadData(), and it
> works too.
Thanks for testing!
> So I wonder how to understand "To assure that all data is
> sent and received on a connected socket before it is closed, an
> application should use shutdown to close connection before calling
> closesocket." in [1].
I suppose their documentation has evolved over time. This sentence
probably predates their explicit acknowledgement in [2] that you don't
have to call shutdown(). Maybe, once upon a time with very old
versions of Winsock, you did have to do so if you wanted graceful close.
I'll push the close-only change in a little bit.
regards, tom lane