summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2020-10-15 16:50:57 +0000
committerTom Lane2020-10-15 16:50:57 +0000
commit85834023a95e16d1d3fe73b0608e1608573753c3 (patch)
treea1c4fa673a81d0d6965360f3aee7b492a92b9ffe /src/include
parentcc1fc7b862a38c22f584acc40b7b782d54550d69 (diff)
In the postmaster, rely on the signal infrastructure to block signals.
POSIX sigaction(2) can be told to block a set of signals while a signal handler executes. Make use of that instead of manually blocking and unblocking signals in the postmaster's signal handlers. This should save a few cycles, but more importantly it prevents recursive invocation of signal handlers when many signals arrive in close succession. (Assuming that the platform's signal infrastructure is designed to avoid consuming stack space in that case, but this is demonstrably true at least on Linux.) The existing code has been seen to recurse to the point of stack overflow, either in the postmaster or in a forked-off child. Back-patch of commit 9abb2bfc0. At the time, we'd only seen excess postmaster stack consumption in the buildfarm; but we now have a user report of it, and that commit has aged enough to have a fair amount of confidence that it doesn't break anything. This still doesn't change anything about the way that it works on Windows. Perhaps someone else would like to fix that? Per bug #16673 from David Geier. Back-patch to 9.6. Although the problem exists in principle before that, we've only seen it actually materialize in connection with heavy use of parallel workers, so it doesn't seem necessary to do anything in 9.5; and the relevant code is different there, too. Discussion: https://postgr.es/m/16673-d278c604f8e34ec0@postgresql.org Discussion: https://postgr.es/m/14878.1570820201@sss.pgh.pa.us
Diffstat (limited to 'src/include')
-rw-r--r--src/include/libpq/pqsignal.h3
-rw-r--r--src/include/port.h5
2 files changed, 3 insertions, 5 deletions
diff --git a/src/include/libpq/pqsignal.h b/src/include/libpq/pqsignal.h
index f292591dfc6..218fd752b34 100644
--- a/src/include/libpq/pqsignal.h
+++ b/src/include/libpq/pqsignal.h
@@ -36,4 +36,7 @@ extern sigset_t UnBlockSig,
extern void pqinitmask(void);
+/* pqsigfunc is declared in src/include/port.h */
+extern pqsigfunc pqsignal_pm(int signo, pqsigfunc func);
+
#endif /* PQSIGNAL_H */
diff --git a/src/include/port.h b/src/include/port.h
index c97d9be2502..5c0aaa09c63 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -456,11 +456,6 @@ extern int pg_mkdir_p(char *path, int omode);
/* port/pqsignal.c */
typedef void (*pqsigfunc) (int signo);
extern pqsigfunc pqsignal(int signo, pqsigfunc func);
-#ifndef WIN32
-extern pqsigfunc pqsignal_no_restart(int signo, pqsigfunc func);
-#else
-#define pqsignal_no_restart(signo, func) pqsignal(signo, func)
-#endif
/* port/quotes.c */
extern char *escape_single_quotes_ascii(const char *src);