mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Move interrupt-handling code into subroutines.
Some auxiliary processes, as well as the autovacuum launcher, have interrupt handling code directly in their main loops. Try to abstract things a little better by moving it into separate functions. This doesn't make any functional difference, and leaves in place relatively large differences among processes in how interrupts are handled, but hopefully it at least makes it easier to see the commonalities and differences across process types. 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:
@ -169,6 +169,7 @@ static pg_time_t last_xlog_switch_time;
|
||||
|
||||
/* Prototypes for private functions */
|
||||
|
||||
static void HandleCheckpointerInterrupts();
|
||||
static void CheckArchiveTimeout(void);
|
||||
static bool IsCheckpointOnSchedule(double progress);
|
||||
static bool ImmediateCheckpointRequested(void);
|
||||
@ -350,37 +351,7 @@ CheckpointerMain(void)
|
||||
* Process any requests or signals received recently.
|
||||
*/
|
||||
AbsorbSyncRequests();
|
||||
|
||||
if (got_SIGHUP)
|
||||
{
|
||||
got_SIGHUP = false;
|
||||
ProcessConfigFile(PGC_SIGHUP);
|
||||
|
||||
/*
|
||||
* Checkpointer is the last process to shut down, so we ask it to
|
||||
* hold the keys for a range of other tasks required most of which
|
||||
* have nothing to do with checkpointing at all.
|
||||
*
|
||||
* For various reasons, some config values can change dynamically
|
||||
* so the primary copy of them is held in shared memory to make
|
||||
* sure all backends see the same value. We make Checkpointer
|
||||
* responsible for updating the shared memory copy if the
|
||||
* parameter setting changes because of SIGHUP.
|
||||
*/
|
||||
UpdateSharedMemoryConfig();
|
||||
}
|
||||
if (shutdown_requested)
|
||||
{
|
||||
/*
|
||||
* From here on, elog(ERROR) should end with exit(1), not send
|
||||
* control back to the sigsetjmp block above
|
||||
*/
|
||||
ExitOnAnyError = true;
|
||||
/* Close down the database */
|
||||
ShutdownXLOG(0, 0);
|
||||
/* Normal exit from the checkpointer is here */
|
||||
proc_exit(0); /* done */
|
||||
}
|
||||
HandleCheckpointerInterrupts();
|
||||
|
||||
/*
|
||||
* Detect a pending checkpoint request by checking whether the flags
|
||||
@ -558,6 +529,44 @@ CheckpointerMain(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Process any new interrupts.
|
||||
*/
|
||||
static void
|
||||
HandleCheckpointerInterrupts(void)
|
||||
{
|
||||
if (got_SIGHUP)
|
||||
{
|
||||
got_SIGHUP = false;
|
||||
ProcessConfigFile(PGC_SIGHUP);
|
||||
|
||||
/*
|
||||
* Checkpointer is the last process to shut down, so we ask it to
|
||||
* hold the keys for a range of other tasks required most of which
|
||||
* have nothing to do with checkpointing at all.
|
||||
*
|
||||
* For various reasons, some config values can change dynamically
|
||||
* so the primary copy of them is held in shared memory to make
|
||||
* sure all backends see the same value. We make Checkpointer
|
||||
* responsible for updating the shared memory copy if the
|
||||
* parameter setting changes because of SIGHUP.
|
||||
*/
|
||||
UpdateSharedMemoryConfig();
|
||||
}
|
||||
if (shutdown_requested)
|
||||
{
|
||||
/*
|
||||
* From here on, elog(ERROR) should end with exit(1), not send
|
||||
* control back to the sigsetjmp block above
|
||||
*/
|
||||
ExitOnAnyError = true;
|
||||
/* Close down the database */
|
||||
ShutdownXLOG(0, 0);
|
||||
/* Normal exit from the checkpointer is here */
|
||||
proc_exit(0); /* done */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CheckArchiveTimeout -- check for archive_timeout and switch xlog files
|
||||
*
|
||||
|
Reference in New Issue
Block a user