]> granicus.if.org Git - postgresql/commitdiff
Ignore interrupts during quickdie().
authorNoah Misch <noah@leadboat.com>
Thu, 12 Sep 2013 00:10:15 +0000 (20:10 -0400)
committerNoah Misch <noah@leadboat.com>
Thu, 12 Sep 2013 00:14:17 +0000 (20:14 -0400)
Once the administrator has called for an immediate shutdown or a backend
crash has triggered a reinitialization, no mere SIGINT or SIGTERM should
change that course.  Such derailment remains possible when the signal
arrives before quickdie() blocks signals.  That being a narrow race
affecting most PostgreSQL signal handlers in some way, leave it for
another patch.  Back-patch this to all supported versions.

src/backend/tcop/postgres.c

index bb34fc751dd61e76c3e51be717a38d13fe6d2b17..470184bc5bbe96cc8c0f66cc283e42a3e781c126 100644 (file)
@@ -2522,6 +2522,13 @@ quickdie(SIGNAL_ARGS)
        sigaddset(&BlockSig, SIGQUIT);          /* prevent nested calls */
        PG_SETMASK(&BlockSig);
 
+       /*
+        * Prevent interrupts while exiting; though we just blocked signals that
+        * would queue new interrupts, one may have been pending.  We don't want a
+        * quickdie() downgraded to a mere query cancel.
+        */
+       HOLD_INTERRUPTS();
+
        /*
         * If we're aborting out of client auth, don't risk trying to send
         * anything to the client; we will likely violate the protocol, not to