Commit fb7df896 authored by Heikki Linnakangas's avatar Heikki Linnakangas

Reload config file in startup process on SIGHUP.

Fujii Masao
parent 820984ba
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.332 2009/02/23 09:28:49 heikki Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.333 2009/03/04 13:56:40 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -429,6 +429,7 @@ static bool InRedo = false; ...@@ -429,6 +429,7 @@ static bool InRedo = false;
/* /*
* Flag set by interrupt handlers for later service in the redo loop. * 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; static volatile sig_atomic_t shutdown_requested = false;
/* /*
* Flag set when executing a restore command, to tell SIGTERM signal handler * Flag set when executing a restore command, to tell SIGTERM signal handler
...@@ -5362,6 +5363,15 @@ StartupXLOG(void) ...@@ -5362,6 +5363,15 @@ StartupXLOG(void)
} }
#endif #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 * Check if we were requested to exit without finishing
* recovery. * recovery.
...@@ -7641,6 +7651,13 @@ startupproc_quickdie(SIGNAL_ARGS) ...@@ -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 */ /* SIGTERM: set flag to abort redo and exit */
static void static void
StartupProcShutdownHandler(SIGNAL_ARGS) StartupProcShutdownHandler(SIGNAL_ARGS)
...@@ -7667,8 +7684,8 @@ StartupProcessMain(void) ...@@ -7667,8 +7684,8 @@ StartupProcessMain(void)
/* /*
* Properly accept or ignore signals the postmaster might send us * Properly accept or ignore signals the postmaster might send us
*/ */
pqsignal(SIGHUP, SIG_IGN); /* ignore config file updates */ pqsignal(SIGHUP, StartupProcSigHupHandler); /* reload config file */
pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */ pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */
pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */ pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */ pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */
pqsignal(SIGALRM, SIG_IGN); pqsignal(SIGALRM, SIG_IGN);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.575 2009/03/03 10:42:05 heikki Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.576 2009/03/04 13:56:40 heikki Exp $
* *
* NOTES * NOTES
* *
...@@ -1949,6 +1949,8 @@ SIGHUP_handler(SIGNAL_ARGS) ...@@ -1949,6 +1949,8 @@ SIGHUP_handler(SIGNAL_ARGS)
(errmsg("received SIGHUP, reloading configuration files"))); (errmsg("received SIGHUP, reloading configuration files")));
ProcessConfigFile(PGC_SIGHUP); ProcessConfigFile(PGC_SIGHUP);
SignalChildren(SIGHUP); SignalChildren(SIGHUP);
if (StartupPID != 0)
signal_child(StartupPID, SIGHUP);
if (BgWriterPID != 0) if (BgWriterPID != 0)
signal_child(BgWriterPID, SIGHUP); signal_child(BgWriterPID, SIGHUP);
if (WalWriterPID != 0) if (WalWriterPID != 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment