Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/port/atomics.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/backend/port/atomics.c b/src/backend/port/atomics.c
index 3350fb7df30..439b3c18c7b 100644
--- a/src/backend/port/atomics.c
+++ b/src/backend/port/atomics.c
@@ -20,15 +20,32 @@
*/
#define ATOMICS_INCLUDE_DEFINITIONS
+#include "miscadmin.h"
#include "port/atomics.h"
#include "storage/spin.h"
#ifdef PG_HAVE_MEMORY_BARRIER_EMULATION
+#ifdef WIN32
+#error "barriers are required (and provided) on WIN32 platforms"
+#endif
+#include <sys/types.h>
+#include <signal.h>
+#endif
+
+#ifdef PG_HAVE_MEMORY_BARRIER_EMULATION
void
pg_spinlock_barrier(void)
{
- S_LOCK(&dummy_spinlock);
- S_UNLOCK(&dummy_spinlock);
+ /*
+ * NB: we have to be reentrant here, some barriers are placed in signal
+ * handlers.
+ *
+ * We use kill(0) for the fallback barrier as we assume that kernels on
+ * systems old enough to require fallback barrier support will include an
+ * appropriate barrier while checking the existence of the postmaster
+ * pid.
+ */
+ (void) kill(PostmasterPid, 0);
}
#endif