From 99698140394a644e90d46798ae34e66a141a8d98 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 4 Mar 2009 13:56:40 +0000 Subject: [PATCH] Reload config file in startup process on SIGHUP. Fujii Masao --- src/backend/access/transam/xlog.c | 21 +++++++++++++++++++-- src/backend/postmaster/postmaster.c | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index bc8372ce3a..3539e9a946 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -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); diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index a427a1b36e..b1e5bb8617 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -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) -- 2.39.5