1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

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
This commit is contained in:
Robert Haas
2019-12-17 13:03:57 -05:00
parent 5910d6c7e3
commit 1e53fe0e70
8 changed files with 37 additions and 156 deletions

View File

@@ -92,9 +92,6 @@ static void logicalrep_worker_onexit(int code, Datum arg);
static void logicalrep_worker_detach(void);
static void logicalrep_worker_cleanup(LogicalRepWorker *worker);
/* Flags set by signal handlers */
static volatile sig_atomic_t got_SIGHUP = false;
static bool on_commit_launcher_wakeup = false;
Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
@@ -714,20 +711,6 @@ logicalrep_worker_onexit(int code, Datum arg)
ApplyLauncherWakeup();
}
/* SIGHUP: set flag to reload configuration at next convenient time */
static void
logicalrep_launcher_sighup(SIGNAL_ARGS)
{
int save_errno = errno;
got_SIGHUP = true;
/* Waken anything waiting on the process latch */
SetLatch(MyLatch);
errno = save_errno;
}
/*
* Count the number of registered (not necessarily running) sync workers
* for a subscription.
@@ -972,7 +955,7 @@ ApplyLauncherMain(Datum main_arg)
LogicalRepCtx->launcher_pid = MyProcPid;
/* Establish signal handlers. */
pqsignal(SIGHUP, logicalrep_launcher_sighup);
pqsignal(SIGTERM, PostgresSigHupHandler);
pqsignal(SIGTERM, die);
BackgroundWorkerUnblockSignals();
@@ -1061,9 +1044,9 @@ ApplyLauncherMain(Datum main_arg)
CHECK_FOR_INTERRUPTS();
}
if (got_SIGHUP)
if (ConfigReloadPending)
{
got_SIGHUP = false;
ConfigReloadPending = false;
ProcessConfigFile(PGC_SIGHUP);
}
}

View File

@@ -111,9 +111,6 @@ static void store_flush_position(XLogRecPtr remote_lsn);
static void maybe_reread_subscription(void);
/* Flags set by signal handlers */
static volatile sig_atomic_t got_SIGHUP = false;
/*
* Should this worker apply changes for given relation.
*
@@ -1270,9 +1267,9 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
CHECK_FOR_INTERRUPTS();
}
if (got_SIGHUP)
if (ConfigReloadPending)
{
got_SIGHUP = false;
ConfigReloadPending = false;
ProcessConfigFile(PGC_SIGHUP);
}
@@ -1563,20 +1560,6 @@ subscription_change_cb(Datum arg, int cacheid, uint32 hashvalue)
MySubscriptionValid = false;
}
/* SIGHUP: set flag to reload configuration at next convenient time */
static void
logicalrep_worker_sighup(SIGNAL_ARGS)
{
int save_errno = errno;
got_SIGHUP = true;
/* Waken anything waiting on the process latch */
SetLatch(MyLatch);
errno = save_errno;
}
/* Logical Replication Apply worker entry point */
void
ApplyWorkerMain(Datum main_arg)
@@ -1592,7 +1575,7 @@ ApplyWorkerMain(Datum main_arg)
logicalrep_worker_attach(worker_slot);
/* Setup signal handling */
pqsignal(SIGHUP, logicalrep_worker_sighup);
pqsignal(SIGHUP, PostgresSigHupHandler);
pqsignal(SIGTERM, die);
BackgroundWorkerUnblockSignals();