pg-sigsetjmp.patch
application/octet-stream
Filename: pg-sigsetjmp.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/postmaster/autovacuum.c | 2 | 2 |
| src/backend/postmaster/bgworker.c | 1 | 1 |
| src/backend/postmaster/bgwriter.c | 2 | 2 |
| src/backend/postmaster/checkpointer.c | 2 | 2 |
| src/backend/postmaster/walwriter.c | 1 | 1 |
| src/backend/tcop/postgres.c | 7 | 7 |
| src/backend/utils/misc/guc-file.l | 1 | 1 |
| src/bin/psql/command.c | 1 | 1 |
| src/bin/psql/copy.c | 1 | 1 |
| src/bin/psql/mainloop.c | 1 | 1 |
| src/include/c.h | 3 | 1 |
| src/include/utils/elog.h | 1 | 1 |
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 00b1e823af..9facfd4ee3 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -506,7 +506,7 @@ AutoVacLauncherMain(int argc, char *argv[])
*
* This code is a stripped down version of PostgresMain error recovery.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
@@ -1576,7 +1576,7 @@ AutoVacWorkerMain(int argc, char *argv[])
*
* See notes in postgres.c about the design of this coding.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Prevents interrupts while cleaning up */
HOLD_INTERRUPTS();
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 28af6f0f07..8238d721f3 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -767,7 +767,7 @@ StartBackgroundWorker(void)
*
* See notes in postgres.c about the design of this coding.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
index 9ad74ee977..8b1596c658 100644
--- a/src/backend/postmaster/bgwriter.c
+++ b/src/backend/postmaster/bgwriter.c
@@ -171,7 +171,7 @@ BackgroundWriterMain(void)
*
* See notes in postgres.c about the design of this coding.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
@@ -268,7 +268,7 @@ BackgroundWriterMain(void)
{
/*
* From here on, elog(ERROR) should end with exit(1), not send
- * control back to the sigsetjmp block above
+ * control back to the pg_sigsetjmp block above
*/
ExitOnAnyError = true;
/* Normal exit from the bgwriter is here */
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index e48ebd557f..682446e764 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -253,7 +253,7 @@ CheckpointerMain(void)
*
* See notes in postgres.c about the design of this coding.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
@@ -392,7 +392,7 @@ CheckpointerMain(void)
{
/*
* From here on, elog(ERROR) should end with exit(1), not send
- * control back to the sigsetjmp block above
+ * control back to the pg_sigsetjmp block above
*/
ExitOnAnyError = true;
/* Close down the database */
diff --git a/src/backend/postmaster/walwriter.c b/src/backend/postmaster/walwriter.c
index 7b89e02428..4394b1e260 100644
--- a/src/backend/postmaster/walwriter.c
+++ b/src/backend/postmaster/walwriter.c
@@ -151,7 +151,7 @@ WalWriterMain(void)
*
* This code is heavily based on bgwriter.c, q.v.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index b8d860ebdb..67a72769fb 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3822,15 +3822,15 @@ PostgresMain(int argc, char *argv[],
* during error recovery. (If we get into an infinite loop thereby, it
* will soon be stopped by overflow of elog.c's internal state stack.)
*
- * Note that we use sigsetjmp(..., 1), so that this function's signal mask
- * (to wit, UnBlockSig) will be restored when longjmp'ing to here. This
- * is essential in case we longjmp'd out of a signal handler on a platform
- * where that leaves the signal blocked. It's not redundant with the
- * unblock in AbortTransaction() because the latter is only called if we
- * were inside a transaction.
+ * Note that we use pg_sigsetjmp(..., 1), so that this function's signal
+ * mask (to wit, UnBlockSig) will be restored when longjmp'ing to here.
+ * This is essential in case we longjmp'd out of a signal handler on a
+ * platform where that leaves the signal blocked. It's not redundant with
+ * the unblock in AbortTransaction() because the latter is only called if
+ * we were inside a transaction.
*/
- if (sigsetjmp(local_sigjmp_buf, 1) != 0)
+ if (pg_sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/*
* NOTE: if you are tempted to add more code in this if-block,
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index f01b814c6e..93caeb3c48 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -704,7 +704,7 @@ ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
int errorcount;
int token;
- if (sigsetjmp(flex_fatal_jmp, 1) == 0)
+ if (pg_sigsetjmp(flex_fatal_jmp, 1) == 0)
GUC_flex_fatal_jmp = &flex_fatal_jmp;
else
{
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 4e04459d45..b9f5946e25 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4423,7 +4423,7 @@ do_watch(PQExpBuffer query_buf, double sleep)
* through the loop since it's conceivable something inside
* PSQLexecWatch could change sigint_interrupt_jmp.
*/
- if (sigsetjmp(sigint_interrupt_jmp, 1) != 0)
+ if (pg_sigsetjmp(sigint_interrupt_jmp, 1) != 0)
break;
/*
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 724ea9211a..ab27c4b5ab 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -521,7 +521,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary, PGresult **res)
* Establish longjmp destination for exiting from wait-for-input. (This is
* only effective while sigint_interrupt_enabled is TRUE.)
*/
- if (sigsetjmp(sigint_interrupt_jmp, 1) != 0)
+ if (pg_sigsetjmp(sigint_interrupt_jmp, 1) != 0)
{
/* got here with longjmp */
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index 0162ee8d2f..d2ebaaabda 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -108,7 +108,7 @@ MainLoop(FILE *source)
* must re-do this each time through the loop for safety, since the
* jmpbuf might get changed during command execution.
*/
- if (sigsetjmp(sigint_interrupt_jmp, 1) != 0)
+ if (pg_sigsetjmp(sigint_interrupt_jmp, 1) != 0)
{
/* got here with longjmp */
diff --git a/src/include/c.h b/src/include/c.h
index 9066e3c578..6a934c7faf 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -1086,8 +1086,10 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
*/
#ifdef WIN32
#define sigjmp_buf jmp_buf
-#define sigsetjmp(x,y) setjmp(x)
+#define pg_sigsetjmp(x,y) setjmp(x)
#define siglongjmp longjmp
+#else
+#define pg_sigsetjmp(x,y) sigsetjmp(x,y)
#endif
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 7bfd25a9e9..dc666930b4 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -286,7 +286,7 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
sigjmp_buf *save_exception_stack = PG_exception_stack; \
ErrorContextCallback *save_context_stack = error_context_stack; \
sigjmp_buf local_sigjmp_buf; \
- if (sigsetjmp(local_sigjmp_buf, 0) == 0) \
+ if (pg_sigsetjmp(local_sigjmp_buf, 0) == 0) \
{ \
PG_exception_stack = &local_sigjmp_buf