summaryrefslogtreecommitdiff
path: root/src/common/exec.c
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2015-01-07 22:35:44 -0500
committerNoah Misch <noah@leadboat.com>2015-01-07 22:36:35 -0500
commit83fb1ca5cf393f3a12930bd9275a711cd858c823 (patch)
tree32ed00cbde0c67dd3015e5e6a100a7f4e9f336f3 /src/common/exec.c
parente8f82b4163edc806ecefdcfa6dfed092678218c9 (diff)
On Darwin, detect and report a multithreaded postmaster.
Darwin --enable-nls builds use a substitute setlocale() that may start a thread. Buildfarm member orangutan experienced BackendList corruption on account of different postmaster threads executing signal handlers simultaneously. Furthermore, a multithreaded postmaster risks undefined behavior from sigprocmask() and fork(). Emit LOG messages about the problem and its workaround. Back-patch to 9.0 (all supported versions).
Diffstat (limited to 'src/common/exec.c')
-rw-r--r--src/common/exec.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/exec.c b/src/common/exec.c
index 037bef2210c..cdf20a60af2 100644
--- a/src/common/exec.c
+++ b/src/common/exec.c
@@ -556,8 +556,20 @@ set_pglocale_pgservice(const char *argv0, const char *app)
/* don't set LC_ALL in the backend */
if (strcmp(app, PG_TEXTDOMAIN("postgres")) != 0)
+ {
setlocale(LC_ALL, "");
+ /*
+ * One could make a case for reproducing here PostmasterMain()'s test
+ * for whether the process is multithreaded. Unlike the postmaster,
+ * no frontend program calls sigprocmask() or otherwise provides for
+ * mutual exclusion between signal handlers. While frontends using
+ * fork(), if multithreaded, are formally exposed to undefined
+ * behavior, we have not witnessed a concrete bug. Therefore,
+ * complaining about multithreading here may be mere pedantry.
+ */
+ }
+
if (find_my_exec(argv0, my_exec_path) < 0)
return;