diff options
author | Robert Haas <rhaas@postgresql.org> | 2019-12-17 13:03:57 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2019-12-17 13:03:57 -0500 |
commit | 1e53fe0e70f610c34f4c9e770d108cd94151342c (patch) | |
tree | 371a110c218d1b236a1f27561c329f11d31195c2 /src/backend/postmaster/pgstat.c | |
parent | 5910d6c7e311f0b14e3d3cb9ce3597c01d3a3cde (diff) | |
download | postgresql-1e53fe0e70f610c34f4c9e770d108cd94151342c.tar.gz postgresql-1e53fe0e70f610c34f4c9e770d108cd94151342c.zip |
Use PostgresSigHupHandler in more places.
There seems to be no reason for every background process to have
its own flag indicating that a config-file reload is needed.
Instead, let's just use ConfigFilePending for that purpose
everywhere.
Patch by me, reviewed by Andres Freund and Daniel Gustafsson.
Discussion: http://postgr.es/m/CA+TgmoZwDk=BguVDVa+qdA6SBKef=PKbaKDQALTC_9qoz1mJqg@mail.gmail.com
Diffstat (limited to 'src/backend/postmaster/pgstat.c')
-rw-r--r-- | src/backend/postmaster/pgstat.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index fabcf31de8c..96a9e09cedc 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -264,7 +264,6 @@ static List *pending_write_requests = NIL; /* Signal handler flags */ static volatile bool need_exit = false; -static volatile bool got_SIGHUP = false; /* * Total time charged to functions so far in the current backend. @@ -285,7 +284,6 @@ static pid_t pgstat_forkexec(void); NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]) pg_attribute_noreturn(); static void pgstat_exit(SIGNAL_ARGS); static void pgstat_beshutdown_hook(int code, Datum arg); -static void pgstat_sighup_handler(SIGNAL_ARGS); static PgStat_StatDBEntry *pgstat_get_db_entry(Oid databaseid, bool create); static PgStat_StatTabEntry *pgstat_get_tab_entry(PgStat_StatDBEntry *dbentry, @@ -4434,7 +4432,7 @@ PgstatCollectorMain(int argc, char *argv[]) * except SIGHUP and SIGQUIT. Note we don't need a SIGUSR1 handler to * support latch operations, because we only use a local latch. */ - pqsignal(SIGHUP, pgstat_sighup_handler); + pqsignal(SIGHUP, PostgresSigHupHandler); pqsignal(SIGINT, SIG_IGN); pqsignal(SIGTERM, SIG_IGN); pqsignal(SIGQUIT, pgstat_exit); @@ -4466,10 +4464,10 @@ PgstatCollectorMain(int argc, char *argv[]) * message. (This effectively means that if backends are sending us stuff * like mad, we won't notice postmaster death until things slack off a * bit; which seems fine.) To do that, we have an inner loop that - * iterates as long as recv() succeeds. We do recognize got_SIGHUP inside - * the inner loop, which means that such interrupts will get serviced but - * the latch won't get cleared until next time there is a break in the - * action. + * iterates as long as recv() succeeds. We do check ConfigReloadPending + * inside the inner loop, which means that such interrupts will get + * serviced but the latch won't get cleared until next time there is a + * break in the action. */ for (;;) { @@ -4491,9 +4489,9 @@ PgstatCollectorMain(int argc, char *argv[]) /* * Reload configuration if we got SIGHUP from the postmaster. */ - if (got_SIGHUP) + if (ConfigReloadPending) { - got_SIGHUP = false; + ConfigReloadPending = false; ProcessConfigFile(PGC_SIGHUP); } @@ -4691,18 +4689,6 @@ pgstat_exit(SIGNAL_ARGS) errno = save_errno; } -/* SIGHUP handler for collector process */ -static void -pgstat_sighup_handler(SIGNAL_ARGS) -{ - int save_errno = errno; - - got_SIGHUP = true; - SetLatch(MyLatch); - - errno = save_errno; -} - /* * Subroutine to clear stats in a database entry * |