@@ -102,6 +102,7 @@ static bool pgarch_archiveXlog(char *xlog);
102102static bool pgarch_readyXlog (char * xlog );
103103static void pgarch_archiveDone (char * xlog );
104104static void pgarch_die (int code , Datum arg );
105+ static void HandlePgArchInterrupts (void );
105106
106107/* Report shared memory space needed by PgArchShmemInit */
107108Size
@@ -257,12 +258,8 @@ pgarch_MainLoop(void)
257258 /* When we get SIGUSR2, we do one more archive cycle, then exit */
258259 time_to_stop = ready_to_stop ;
259260
260- /* Check for config update */
261- if (ConfigReloadPending )
262- {
263- ConfigReloadPending = false;
264- ProcessConfigFile (PGC_SIGHUP );
265- }
261+ /* Check for barrier events and config update */
262+ HandlePgArchInterrupts ();
266263
267264 /*
268265 * If we've gotten SIGTERM, we normally just sit and do nothing until
@@ -355,15 +352,11 @@ pgarch_ArchiverCopyLoop(void)
355352 return ;
356353
357354 /*
358- * Check for config update. This is so that we'll adopt a new
359- * setting for archive_command as soon as possible, even if there
360- * is a backlog of files to be archived.
355+ * Check for barrier events and config update. This is so that
356+ * we'll adopt a new setting for archive_command as soon as
357+ * possible, even if there is a backlog of files to be archived.
361358 */
362- if (ConfigReloadPending )
363- {
364- ConfigReloadPending = false;
365- ProcessConfigFile (PGC_SIGHUP );
366- }
359+ HandlePgArchInterrupts ();
367360
368361 /* can't do anything if no command ... */
369362 if (!XLogArchiveCommandSet ())
@@ -703,3 +696,23 @@ pgarch_die(int code, Datum arg)
703696{
704697 PgArch -> pgprocno = INVALID_PGPROCNO ;
705698}
699+
700+ /*
701+ * Interrupt handler for WAL archiver process.
702+ *
703+ * This is called in the loops pgarch_MainLoop and pgarch_ArchiverCopyLoop.
704+ * It checks for barrier events and config update, but not shutdown request
705+ * because how to handle shutdown request is different between those loops.
706+ */
707+ static void
708+ HandlePgArchInterrupts (void )
709+ {
710+ if (ProcSignalBarrierPending )
711+ ProcessProcSignalBarrier ();
712+
713+ if (ConfigReloadPending )
714+ {
715+ ConfigReloadPending = false;
716+ ProcessConfigFile (PGC_SIGHUP );
717+ }
718+ }
0 commit comments