Reload config file in startup process on SIGHUP.
authorHeikki Linnakangas <heikki@enterprisedb.com>
Wed, 4 Mar 2009 13:56:40 +0000 (13:56 +0000)
committerHeikki Linnakangas <heikki@enterprisedb.com>
Wed, 4 Mar 2009 13:56:40 +0000 (13:56 +0000)
Fujii Masao

src/backend/access/transam/xlog.c
src/backend/postmaster/postmaster.c

index bc8372ce3a1522f6db1dd4efc945e7b231bcc2a7..3539e9a946e6e1eb6c2b4c63c6b60c4af5a75fac 100644 (file)
@@ -429,6 +429,7 @@ static bool InRedo = false;
 /*
  * Flag set by interrupt handlers for later service in the redo loop.
  */
+static volatile sig_atomic_t got_SIGHUP = false;
 static volatile sig_atomic_t shutdown_requested = false;
 /*
  * Flag set when executing a restore command, to tell SIGTERM signal handler
@@ -5362,6 +5363,15 @@ StartupXLOG(void)
                                }
 #endif
 
+                               /*
+                                * Check if we were requested to re-read config file.
+                                */
+                               if (got_SIGHUP)
+                               {
+                                       got_SIGHUP = false;
+                                       ProcessConfigFile(PGC_SIGHUP);
+                               }
+
                                /*
                                 * Check if we were requested to exit without finishing
                                 * recovery.
@@ -7641,6 +7651,13 @@ startupproc_quickdie(SIGNAL_ARGS)
 }
 
 
+/* SIGHUP: set flag to re-read config file at next convenient time */
+static void
+StartupProcSigHupHandler(SIGNAL_ARGS)
+{
+       got_SIGHUP = true;
+}
+
 /* SIGTERM: set flag to abort redo and exit */
 static void
 StartupProcShutdownHandler(SIGNAL_ARGS)
@@ -7667,8 +7684,8 @@ StartupProcessMain(void)
        /*
         * Properly accept or ignore signals the postmaster might send us
         */
-       pqsignal(SIGHUP, SIG_IGN);      /* ignore config file updates */
-       pqsignal(SIGINT, SIG_IGN);              /* ignore query cancel */
+       pqsignal(SIGHUP, StartupProcSigHupHandler);      /* reload config file */
+       pqsignal(SIGINT, SIG_IGN);                                      /* ignore query cancel */
        pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
        pqsignal(SIGQUIT, startupproc_quickdie);                /* hard crash time */
        pqsignal(SIGALRM, SIG_IGN);
index a427a1b36e1977f25279dca10021cf4942275b1f..b1e5bb86170a6a1340fb474fec7c508f5070aa6a 100644 (file)
@@ -1949,6 +1949,8 @@ SIGHUP_handler(SIGNAL_ARGS)
                                (errmsg("received SIGHUP, reloading configuration files")));
                ProcessConfigFile(PGC_SIGHUP);
                SignalChildren(SIGHUP);
+               if (StartupPID != 0)
+                       signal_child(StartupPID, SIGHUP);
                if (BgWriterPID != 0)
                        signal_child(BgWriterPID, SIGHUP);
                if (WalWriterPID != 0)