postgresql/src/include/port
Thomas Munro e2f0f8ed25 Check for STATUS_DELETE_PENDING on Windows.
1.  Update our open() wrapper to check for NT's STATUS_DELETE_PENDING
and translate it to Unix-like errors.  This is done with
RtlGetLastNtStatus(), which is dynamically loaded from ntdll.  A new
file win32ntdll.c centralizes lookup of NT functions, in case we decide
to add more in the future.

2.  Remove non-working code that was trying to do something similar for
stat(), and just reuse the open() wrapper code.  As a side effect,
stat() also gains resilience against "sharing violation" errors.

3.  Since stat() is used very early in process startup, remove the
requirement that the Win32 signal event has been created before
pgwin32_open_handle() is reached.  Instead, teach pg_usleep() to fall
back to a non-interruptible sleep if reached before the signal event is
available.

This could be back-patched, but for now it's in master only.  The
problem has apparently been with us for a long time and generated only a
few complaints.  Proposed patches trigger it more often, which led to
this investigation and fix.

Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Alexander Lakhin <exclusion@gmail.com>
Reviewed-by: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGJz_pZTF9mckn6XgSv69%2BjGwdgLkxZ6b3NWGLBCVjqUZA%40mail.gmail.com
2021-12-10 16:19:43 +13:00
..
atomics Update copyright for 2021 2021-01-02 13:06:25 -05:00
win32 Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
win32_msvc Add d_type to our Windows dirent emulation. 2020-09-07 23:38:19 +12:00
aix.h Attempt to work around a 32bit xlc compiler bug from a different place. 2015-08-08 01:19:02 +02:00
atomics.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
cygwin.h Simplify declaring variables exported from libpgcommon and libpgport. 2021-11-29 11:00:00 -05:00
darwin.h Refer to OS X as "macOS", except for the port name which is still "darwin". 2016-09-25 15:40:57 -04:00
freebsd.h Default to wal_sync_method=fdatasync on FreeBSD. 2021-02-15 16:04:59 +13:00
hpux.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
linux.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
netbsd.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
openbsd.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
pg_bitutils.h Simplify declaring variables exported from libpgcommon and libpgport. 2021-11-29 11:00:00 -05:00
pg_bswap.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_crc32c.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_iovec.h Probe for preadv/pwritev in a more macOS-friendly way. 2021-07-12 19:17:35 -04:00
pg_pthread.h Add missing pthread_barrier_t. 2021-03-10 17:44:04 +13:00
solaris.h Remove obsolete HAVE_BUGGY_SOLARIS_STRTOD 2020-08-15 11:27:41 +02:00
win32.h Simplify declaring variables exported from libpgcommon and libpgport. 2021-11-29 11:00:00 -05:00
win32_port.h windows: Define WIN32_LEAN_AND_MEAN to make compilation faster. 2021-10-04 13:16:12 -07:00
win32ntdll.h Check for STATUS_DELETE_PENDING on Windows. 2021-12-10 16:19:43 +13:00