aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-02-18 02:53:46 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-02-18 02:53:46 +0000
commitc89000f34637c3b7e25b8da00cb5c729e86a8c53 (patch)
treeb5c55b249a6593e7f4d0089eaa2dc2fe8cdbef37
parent79c049ddaa2f2c3142519c873d6a3efc6f2f145b (diff)
downloadpostgresql-c89000f34637c3b7e25b8da00cb5c729e86a8c53.tar.gz
postgresql-c89000f34637c3b7e25b8da00cb5c729e86a8c53.zip
Async_NotifyHandler must save and restore ImmediateInterruptOK. Fixes
known problem with failure to respond to 'pg_ctl stop -m fast', and probable problems if SIGINT or SIGTERM arrives while processing a SIGUSR2 interrupt that arrived while waiting for a new client query.
-rw-r--r--src/backend/commands/async.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index a3c27b8f810..fa4c2429dbc 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.91 2002/09/16 01:24:41 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.91.2.1 2003/02/18 02:53:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -599,6 +599,16 @@ Async_NotifyHandler(SIGNAL_ARGS)
if (notifyInterruptEnabled)
{
+ bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+
+ /*
+ * We may be called while ImmediateInterruptOK is true; turn it off
+ * while messing with the NOTIFY state. (We would have to save
+ * and restore it anyway, because PGSemaphore operations inside
+ * ProcessIncomingNotify() might reset it.)
+ */
+ ImmediateInterruptOK = false;
+
/*
* I'm not sure whether some flavors of Unix might allow another
* SIGUSR2 occurrence to recursively interrupt this routine. To
@@ -626,6 +636,13 @@ Async_NotifyHandler(SIGNAL_ARGS)
elog(LOG, "Async_NotifyHandler: done");
}
}
+
+ /*
+ * Restore ImmediateInterruptOK, and check for interrupts if needed.
+ */
+ ImmediateInterruptOK = save_ImmediateInterruptOK;
+ if (save_ImmediateInterruptOK)
+ CHECK_FOR_INTERRUPTS();
}
else
{