postgresql/src/backend/port
Tom Lane f7819baa61 Fix WaitEventSetWait() to handle write-ready waits properly on Windows.
Windows apparently will not detect socket write-ready events unless a
preceding send attempt returned WSAEWOULDBLOCK.  In many usage patterns
that's satisfied by the caller of WaitEvenSetWait(), but not always.

Apply the same solution that we already had in pgwin32_select(), namely to
perform a dummy WSASend() call with len=0.  This will return WSAEWOULDBLOCK
if there's no buffer space (even though it could legitimately do nothing
and report success, which makes me a bit nervous about this solution;
but since it's been working fine in libpq, let's roll with it).

In passing, improve the comments about this in pgwin32_select(), and remove
duplicated code there.

Back-patch to 9.6 where WaitEventSetWait() was introduced.  We might need
to back-patch something similar into predecessor code.  But given the lack
of complaints so far, it's not clear that the case ever gets exercised
in the back branches, so I'm not going to expend effort on it right now.

This should resolve recurring failures on buildfarm member bowerbird,
which has been failing since 1e8a85009 went in.

Diagnosis and patch by Petr Jelinek, cosmetic adjustments by me.

Discussion: https://postgr.es/m/5b6a6d6d-fb45-0afb-2e95-5600063c3dbd@2ndquadrant.com
2017-03-17 14:58:06 -04:00
..
aix Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
dynloader Spelling fixes 2017-03-14 12:58:39 -04:00
hpux Redefine Datum as uintptr_t, instead of unsigned long. 2009-12-31 19:41:37 +00:00
tas Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
win32 Fix WaitEventSetWait() to handle write-ready waits properly on Windows. 2017-03-17 14:58:06 -04:00
.gitignore Combine win32 and unix latch implementations. 2016-03-21 11:03:26 +01:00
atomics.c Remove useless duplicate inclusions of system header files. 2017-02-25 16:12:55 -05:00
Makefile Remove obsolete replacement system() on darwin 2016-08-18 12:00:00 -04:00
posix_sema.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
sysv_sema.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
sysv_shmem.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
win32_sema.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
win32_shmem.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00