mirror of
https://github.com/postgres/postgres.git
synced 2025-06-05 00:02:04 -04:00
Separate the code to start a new worker into its own function. The code is
exactly the same, modulo whitespace.
This commit is contained in:
parent
6287eb7adc
commit
a0abe87f1c
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.36 2007/03/23 21:23:13 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.37 2007/03/23 21:45:17 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -118,6 +118,7 @@ static pid_t avworker_forkexec(void);
|
||||
NON_EXEC_STATIC void AutoVacWorkerMain(int argc, char *argv[]);
|
||||
NON_EXEC_STATIC void AutoVacLauncherMain(int argc, char *argv[]);
|
||||
|
||||
static void do_start_worker(void);
|
||||
static void do_autovacuum(PgStat_StatDBEntry *dbentry);
|
||||
static List *autovac_get_database_list(void);
|
||||
static void test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry,
|
||||
@ -218,9 +219,6 @@ NON_EXEC_STATIC void
|
||||
AutoVacLauncherMain(int argc, char *argv[])
|
||||
{
|
||||
sigjmp_buf local_sigjmp_buf;
|
||||
List *dblist;
|
||||
bool for_xid_wrap;
|
||||
autovac_dbase *db;
|
||||
MemoryContext avlauncher_cxt;
|
||||
|
||||
/* we are a postmaster subprocess now */
|
||||
@ -358,8 +356,6 @@ AutoVacLauncherMain(int argc, char *argv[])
|
||||
|
||||
for (;;)
|
||||
{
|
||||
TransactionId xidForceLimit;
|
||||
ListCell *cell;
|
||||
int worker_pid;
|
||||
|
||||
/*
|
||||
@ -407,6 +403,49 @@ AutoVacLauncherMain(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
do_start_worker();
|
||||
|
||||
sleep:
|
||||
/*
|
||||
* in emergency mode, exit immediately so that the postmaster can
|
||||
* request another run right away if needed.
|
||||
*
|
||||
* XXX -- maybe it would be better to handle this inside the launcher
|
||||
* itself.
|
||||
*/
|
||||
if (!autovacuum_start_daemon)
|
||||
break;
|
||||
|
||||
/* have pgstat read the file again next time */
|
||||
pgstat_clear_snapshot();
|
||||
|
||||
/* now sleep until the next autovac iteration */
|
||||
pg_usleep(autovacuum_naptime * 1000000L);
|
||||
}
|
||||
|
||||
/* Normal exit from the autovac launcher is here */
|
||||
ereport(LOG,
|
||||
(errmsg("autovacuum launcher shutting down")));
|
||||
|
||||
proc_exit(0); /* done */
|
||||
}
|
||||
|
||||
/*
|
||||
* do_start_worker
|
||||
*
|
||||
* Bare-bones procedure for starting an autovacuum worker from the launcher.
|
||||
* It determines what database to work on, sets up shared memory stuff and
|
||||
* signals postmaster to start the worker.
|
||||
*/
|
||||
static void
|
||||
do_start_worker(void)
|
||||
{
|
||||
List *dblist;
|
||||
bool for_xid_wrap;
|
||||
autovac_dbase *db;
|
||||
ListCell *cell;
|
||||
TransactionId xidForceLimit;
|
||||
|
||||
/* Get a list of databases */
|
||||
dblist = autovac_get_database_list();
|
||||
|
||||
@ -486,30 +525,6 @@ AutoVacLauncherMain(int argc, char *argv[])
|
||||
|
||||
SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_WORKER);
|
||||
}
|
||||
|
||||
sleep:
|
||||
/*
|
||||
* in emergency mode, exit immediately so that the postmaster can
|
||||
* request another run right away if needed.
|
||||
*
|
||||
* XXX -- maybe it would be better to handle this inside the launcher
|
||||
* itself.
|
||||
*/
|
||||
if (!autovacuum_start_daemon)
|
||||
break;
|
||||
|
||||
/* have pgstat read the file again next time */
|
||||
pgstat_clear_snapshot();
|
||||
|
||||
/* now sleep until the next autovac iteration */
|
||||
pg_usleep(autovacuum_naptime * 1000000L);
|
||||
}
|
||||
|
||||
/* Normal exit from the autovac launcher is here */
|
||||
ereport(LOG,
|
||||
(errmsg("autovacuum launcher shutting down")));
|
||||
|
||||
proc_exit(0); /* done */
|
||||
}
|
||||
|
||||
/* SIGHUP: set flag to re-read config file at next convenient time */
|
||||
|
Loading…
x
Reference in New Issue
Block a user