Re: Windows: Wrong error message at connection termination
От | Alexander Lakhin |
---|---|
Тема | Re: Windows: Wrong error message at connection termination |
Дата | |
Msg-id | 3a497c66-6685-c1c1-1eb4-1636e9ac5442@gmail.com обсуждение исходный текст |
Ответ на | Re: Windows: Wrong error message at connection termination (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Windows: Wrong error message at connection termination
|
Список | pgsql-hackers |
Hello Tom, 29.11.2021 22:16, Tom Lane wrote: > Hm, yeah, that discussion seems to have slipped through the cracks. > Not sure why it didn't end up in pushing something. > > 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. > > regards, tom lane > > [1] https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-shutdown > [2] https://docs.microsoft.com/en-us/windows/win32/winsock/graceful-shutdown-linger-options-and-socket-closure-2 I've tested the close-only patch with pg_sleep() in pqReadData(), and it works too. 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]. Maybe they mean that shutdown should be used before, but not after closesocket ). Or maybe the Windows' behaviour somehow evolved over time. (With the patch I cannot reproduce the FATAL message loss even on Windows 2012 R2.) So without a practical evidence of the importance of shutdown() I'm inclined to a more simple solution too. As to 268313a95, back in 2003 it was possible to compile server on Windows only using Cygwin (though you could compile libpq with Visual C, see [3]). So "#ifdef WIN32" that is proposed now, will not affect that scenario anyway. Best regards, Alexander [3] https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=doc/src/sgml/install-win32.sgml;hb=268313a95
В списке pgsql-hackers по дате отправления: