Use unnamed POSIX semaphores on Cygwin.
authorThomas Munro <tmunro@postgresql.org>
Thu, 5 Jan 2023 21:09:02 +0000 (10:09 +1300)
committerThomas Munro <tmunro@postgresql.org>
Thu, 5 Jan 2023 21:33:28 +0000 (10:33 +1300)
Testing on CI showed that Cygwin's semctl() can fail with EAGAIN
(possibly due to resource limits in cygserver that could be tuned, not
examined).  Switch to so-called POSIX semaphores instead, which don't
seem to fail in that way (possibly due to a more direct implementation
using Windows semaphore primitives instead of talking to cygserver,
based on a cursory glance at the source).

Other known problems still prevent PostgreSQL from running on Cygwin
without random crashes, but this rarer problem was noticed while
testing.

Discussion: https://postgr.es/m/CA%2BhUKG%2BQ6DU4Ov9LrvUyDcF3oHS4KMRVSKmVGaeePq-kOyG9gA%40mail.gmail.com

meson.build
src/template/cygwin

index 8999170b4d2cb1cc8830144d6282a81237a23817..45fb9dd616eea0d1396b3e0a983b3f7b7a154e09 100644 (file)
@@ -211,6 +211,7 @@ if host_system == 'aix'
   memset_loop_limit = 0
 
 elif host_system == 'cygwin'
+  sema_kind = 'unnamed_posix'
   cppflags += '-D_GNU_SOURCE'
   dlsuffix = '.dll'
   mod_link_args_fmt = ['@0@']
index 3f42e2f8b69c227fec0518acb7289558521d821b..4a03707a8566ce49df1fbe5e44e98338793223b0 100644 (file)
@@ -1,5 +1,10 @@
 # src/template/cygwin
 
+# Prefer unnamed POSIX semaphores if available, unless user overrides choice
+if test x"$PREFERRED_SEMAPHORES" = x"" ; then
+  PREFERRED_SEMAPHORES=UNNAMED_POSIX
+fi
+
 SRCH_LIB="/usr/local/lib"
 
 # This is required for ppoll(2), and perhaps other things