summaryrefslogtreecommitdiff
path: root/src/backend/postmaster
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-10-15 02:49:52 +0000
committerBruce Momjian <bruce@momjian.us>2005-10-15 02:49:52 +0000
commit1dc34982511d91ef8a2b71bdcb870f067c1b3da9 (patch)
tree1046adab1d4b964e0c38afeec0ee6546f61d9a8a /src/backend/postmaster
parent790c01d28099587bbe2c623d4389b62ee49b1dee (diff)
downloadpostgresql-1dc34982511d91ef8a2b71bdcb870f067c1b3da9.tar.gz
Standard pgindent run for 8.1.
Diffstat (limited to 'src/backend/postmaster')
-rw-r--r--src/backend/postmaster/autovacuum.c270
-rw-r--r--src/backend/postmaster/bgwriter.c109
-rw-r--r--src/backend/postmaster/fork_process.c35
-rw-r--r--src/backend/postmaster/pgarch.c53
-rw-r--r--src/backend/postmaster/pgstat.c471
-rw-r--r--src/backend/postmaster/postmaster.c685
-rw-r--r--src/backend/postmaster/syslogger.c120
7 files changed, 854 insertions, 889 deletions
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 9aeecec7a6..1081cf83e9 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.4 2005/08/15 16:25:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.5 2005/10/15 02:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -69,17 +69,17 @@ static time_t last_autovac_start_time = 0;
static time_t last_autovac_stop_time = 0;
/* Memory context for long-lived data */
-static MemoryContext AutovacMemCxt;
+static MemoryContext AutovacMemCxt;
/* struct to keep list of candidate databases for vacuum */
typedef struct autovac_dbase
{
- Oid oid;
- char *name;
- TransactionId frozenxid;
- TransactionId vacuumxid;
+ Oid oid;
+ char *name;
+ TransactionId frozenxid;
+ TransactionId vacuumxid;
PgStat_StatDBEntry *entry;
- int32 age;
+ int32 age;
} autovac_dbase;
/* struct to keep track of tables to vacuum and/or analyze */
@@ -102,12 +102,12 @@ static void process_whole_db(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,
- Form_pg_class classForm,
- Form_pg_autovacuum avForm,
- List **vacuum_tables,
- List **toast_table_ids);
+ Form_pg_class classForm,
+ Form_pg_autovacuum avForm,
+ List **vacuum_tables,
+ List **toast_table_ids);
static void autovacuum_do_vac_analyze(List *relids, bool dovacuum,
- bool doanalyze, bool freeze);
+ bool doanalyze, bool freeze);
/*
@@ -126,16 +126,16 @@ autovac_start(void)
return 0;
/*
- * Do nothing if too soon since last autovacuum exit. This limits
- * how often the daemon runs. Since the time per iteration can be
- * quite variable, it seems more useful to measure/control the time
- * since last subprocess exit than since last subprocess launch.
+ * Do nothing if too soon since last autovacuum exit. This limits how
+ * often the daemon runs. Since the time per iteration can be quite
+ * variable, it seems more useful to measure/control the time since last
+ * subprocess exit than since last subprocess launch.
*
- * However, we *also* check the time since last subprocess launch;
- * this prevents thrashing under fork-failure conditions.
+ * However, we *also* check the time since last subprocess launch; this
+ * prevents thrashing under fork-failure conditions.
*
- * Note that since we will be re-called from the postmaster main loop,
- * we will get another chance later if we do nothing now.
+ * Note that since we will be re-called from the postmaster main loop, we
+ * will get another chance later if we do nothing now.
*
* XXX todo: implement sleep scale factor that existed in contrib code.
*/
@@ -151,14 +151,14 @@ autovac_start(void)
last_autovac_start_time = curtime;
#ifdef EXEC_BACKEND
- switch((AutoVacPID = autovac_forkexec()))
+ switch ((AutoVacPID = autovac_forkexec()))
#else
- switch((AutoVacPID = fork_process()))
+ switch ((AutoVacPID = fork_process()))
#endif
{
case -1:
ereport(LOG,
- (errmsg("could not fork autovacuum process: %m")));
+ (errmsg("could not fork autovacuum process: %m")));
return 0;
#ifndef EXEC_BACKEND
@@ -201,14 +201,14 @@ autovac_forkexec(void)
av[ac++] = "postgres";
av[ac++] = "-forkautovac";
- av[ac++] = NULL; /* filled in by postmaster_forkexec */
+ av[ac++] = NULL; /* filled in by postmaster_forkexec */
av[ac] = NULL;
Assert(ac < lengthof(av));
return postmaster_forkexec(ac, av);
}
-#endif /* EXEC_BACKEND */
+#endif /* EXEC_BACKEND */
/*
* AutoVacMain
@@ -216,12 +216,12 @@ autovac_forkexec(void)
NON_EXEC_STATIC void
AutoVacMain(int argc, char *argv[])
{
- ListCell *cell;
- List *dblist;
- TransactionId nextXid;
- autovac_dbase *db;
- bool whole_db;
- sigjmp_buf local_sigjmp_buf;
+ ListCell *cell;
+ List *dblist;
+ TransactionId nextXid;
+ autovac_dbase *db;
+ bool whole_db;
+ sigjmp_buf local_sigjmp_buf;
/* we are a postmaster subprocess now */
IsUnderPostmaster = true;
@@ -240,18 +240,18 @@ AutoVacMain(int argc, char *argv[])
SetProcessingMode(InitProcessing);
/*
- * Set up signal handlers. We operate on databases much like a
- * regular backend, so we use the same signal handling. See
- * equivalent code in tcop/postgres.c.
+ * Set up signal handlers. We operate on databases much like a regular
+ * backend, so we use the same signal handling. See equivalent code in
+ * tcop/postgres.c.
*
- * Currently, we don't pay attention to postgresql.conf changes
- * that happen during a single daemon iteration, so we can ignore
- * SIGHUP.
+ * Currently, we don't pay attention to postgresql.conf changes that happen
+ * during a single daemon iteration, so we can ignore SIGHUP.
*/
pqsignal(SIGHUP, SIG_IGN);
+
/*
- * Presently, SIGINT will lead to autovacuum shutdown, because that's
- * how we handle ereport(ERROR). It could be improved however.
+ * Presently, SIGINT will lead to autovacuum shutdown, because that's how
+ * we handle ereport(ERROR). It could be improved however.
*/
pqsignal(SIGINT, StatementCancelHandler);
pqsignal(SIGTERM, die);
@@ -282,9 +282,9 @@ AutoVacMain(int argc, char *argv[])
EmitErrorReport();
/*
- * We can now go away. Note that because we'll call InitProcess,
- * a callback will be registered to do ProcKill, which will clean
- * up necessary state.
+ * We can now go away. Note that because we'll call InitProcess, a
+ * callback will be registered to do ProcKill, which will clean up
+ * necessary state.
*/
proc_exit(0);
}
@@ -298,9 +298,8 @@ AutoVacMain(int argc, char *argv[])
dblist = autovac_get_database_list();
/*
- * Get the next Xid that was current as of the last checkpoint.
- * We need it to determine whether databases are about to need
- * database-wide vacuums.
+ * Get the next Xid that was current as of the last checkpoint. We need it
+ * to determine whether databases are about to need database-wide vacuums.
*/
nextXid = GetRecentNextXid();
@@ -309,37 +308,36 @@ AutoVacMain(int argc, char *argv[])
* recently auto-vacuumed, or one that needs database-wide vacuum (to
* prevent Xid wraparound-related data loss).
*
- * Note that a database with no stats entry is not considered, except
- * for Xid wraparound purposes. The theory is that if no one has ever
- * connected to it since the stats were last initialized, it doesn't
- * need vacuuming.
+ * Note that a database with no stats entry is not considered, except for Xid
+ * wraparound purposes. The theory is that if no one has ever connected
+ * to it since the stats were last initialized, it doesn't need vacuuming.
*
* XXX This could be improved if we had more info about whether it needs
* vacuuming before connecting to it. Perhaps look through the pgstats
* data for the database's tables? One idea is to keep track of the
* number of new and dead tuples per database in pgstats. However it
- * isn't clear how to construct a metric that measures that and not
- * cause starvation for less busy databases.
+ * isn't clear how to construct a metric that measures that and not cause
+ * starvation for less busy databases.
*/
db = NULL;
whole_db = false;
foreach(cell, dblist)
{
- autovac_dbase *tmp = lfirst(cell);
- bool this_whole_db;
- int32 freeze_age,
- vacuum_age;
+ autovac_dbase *tmp = lfirst(cell);
+ bool this_whole_db;
+ int32 freeze_age,
+ vacuum_age;
/*
* We look for the database that most urgently needs a database-wide
- * vacuum. We decide that a database-wide vacuum is needed 100000
+ * vacuum. We decide that a database-wide vacuum is needed 100000
* transactions sooner than vacuum.c's vac_truncate_clog() would
* decide to start giving warnings. If any such db is found, we
* ignore all other dbs.
*
- * Unlike vacuum.c, we also look at vacuumxid. This is so that
- * pg_clog can be kept trimmed to a reasonable size.
+ * Unlike vacuum.c, we also look at vacuumxid. This is so that pg_clog
+ * can be kept trimmed to a reasonable size.
*/
freeze_age = (int32) (nextXid - tmp->frozenxid);
vacuum_age = (int32) (nextXid - tmp->vacuumxid);
@@ -373,8 +371,8 @@ AutoVacMain(int argc, char *argv[])
* modified, after the database was dropped from the pg_database
* table. (This is of course a not-very-bulletproof test, but it's
* cheap to make. If we do mistakenly choose a recently dropped
- * database, InitPostgres will fail and we'll drop out until the
- * next autovac run.)
+ * database, InitPostgres will fail and we'll drop out until the next
+ * autovac run.)
*/
if (tmp->entry->destroy != 0)
continue;
@@ -390,12 +388,12 @@ AutoVacMain(int argc, char *argv[])
if (db)
{
/*
- * Report autovac startup to the stats collector. We deliberately
- * do this before InitPostgres, so that the last_autovac_time will
- * get updated even if the connection attempt fails. This is to
- * prevent autovac from getting "stuck" repeatedly selecting an
- * unopenable database, rather than making any progress on stuff
- * it can connect to.
+ * Report autovac startup to the stats collector. We deliberately do
+ * this before InitPostgres, so that the last_autovac_time will get
+ * updated even if the connection attempt fails. This is to prevent
+ * autovac from getting "stuck" repeatedly selecting an unopenable
+ * database, rather than making any progress on stuff it can connect
+ * to.
*/
pgstat_report_autovac(db->oid);
@@ -431,18 +429,18 @@ AutoVacMain(int argc, char *argv[])
/*
* autovac_get_database_list
*
- * Return a list of all databases. Note we cannot use pg_database,
+ * Return a list of all databases. Note we cannot use pg_database,
* because we aren't connected yet; we use the flat database file.
*/
static List *
autovac_get_database_list(void)
{
- char *filename;
- List *dblist = NIL;
- char thisname[NAMEDATALEN];
- FILE *db_file;
- Oid db_id;
- Oid db_tablespace;
+ char *filename;
+ List *dblist = NIL;
+ char thisname[NAMEDATALEN];
+ FILE *db_file;
+ Oid db_id;
+ Oid db_tablespace;
TransactionId db_frozenxid;
TransactionId db_vacuumxid;
@@ -457,7 +455,7 @@ autovac_get_database_list(void)
&db_tablespace, &db_frozenxid,
&db_vacuumxid))
{
- autovac_dbase *db;
+ autovac_dbase *db;
db = (autovac_dbase *) palloc(sizeof(autovac_dbase));
@@ -486,12 +484,12 @@ autovac_get_database_list(void)
static void
process_whole_db(void)
{
- Relation dbRel;
- ScanKeyData entry[1];
- SysScanDesc scan;
- HeapTuple tup;
+ Relation dbRel;
+ ScanKeyData entry[1];
+ SysScanDesc scan;
+ HeapTuple tup;
Form_pg_database dbForm;
- bool freeze;
+ bool freeze;
/* Start a transaction so our commands have one to play into. */
StartTransactionCommand();
@@ -545,23 +543,22 @@ process_whole_db(void)
static void
do_autovacuum(PgStat_StatDBEntry *dbentry)
{
- Relation classRel,
- avRel;
- HeapTuple tuple;
- HeapScanDesc relScan;
- List *vacuum_tables = NIL;
- List *toast_table_ids = NIL;
- ListCell *cell;
+ Relation classRel,
+ avRel;
+ HeapTuple tuple;
+ HeapScanDesc relScan;
+ List *vacuum_tables = NIL;
+ List *toast_table_ids = NIL;
+ ListCell *cell;
PgStat_StatDBEntry *shared;
/* Start a transaction so our commands have one to play into. */
StartTransactionCommand();
/*
- * StartTransactionCommand and CommitTransactionCommand will
- * automatically switch to other contexts. We need this one
- * to keep the list of relations to vacuum/analyze across
- * transactions.
+ * StartTransactionCommand and CommitTransactionCommand will automatically
+ * switch to other contexts. We need this one to keep the list of
+ * relations to vacuum/analyze across transactions.
*/
MemoryContextSwitchTo(AutovacMemCxt);
@@ -574,19 +571,19 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
/*
* Scan pg_class and determine which tables to vacuum.
*
- * The stats subsystem collects stats for toast tables independently
- * of the stats for their parent tables. We need to check those stats
- * since in cases with short, wide tables there might be proportionally
- * much more activity in the toast table than in its parent.
+ * The stats subsystem collects stats for toast tables independently of the
+ * stats for their parent tables. We need to check those stats since in
+ * cases with short, wide tables there might be proportionally much more
+ * activity in the toast table than in its parent.
*
* Since we can only issue VACUUM against the parent table, we need to
* transpose a decision to vacuum a toast table into a decision to vacuum
- * its parent. There's no point in considering ANALYZE on a toast table,
- * either. To support this, we keep a list of OIDs of toast tables that
+ * its parent. There's no point in considering ANALYZE on a toast table,
+ * either. To support this, we keep a list of OIDs of toast tables that
* need vacuuming alongside the list of regular tables. Regular tables
* will be entered into the table list even if they appear not to need
- * vacuuming; we go back and re-mark them after finding all the
- * vacuumable toast tables.
+ * vacuuming; we go back and re-mark them after finding all the vacuumable
+ * toast tables.
*/
relScan = heap_beginscan(classRel, SnapshotNow, 0, NULL);
@@ -595,9 +592,9 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
Form_pg_autovacuum avForm = NULL;
PgStat_StatTabEntry *tabentry;
- SysScanDesc avScan;
+ SysScanDesc avScan;
HeapTuple avTup;
- ScanKeyData entry[1];
+ ScanKeyData entry[1];
Oid relid;
/* Consider only regular and toast tables. */
@@ -606,8 +603,8 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
continue;
/*
- * Skip temp tables (i.e. those in temp namespaces). We cannot
- * safely process other backends' temp tables.
+ * Skip temp tables (i.e. those in temp namespaces). We cannot safely
+ * process other backends' temp tables.
*/
if (isTempNamespace(classForm->relnamespace))
continue;
@@ -687,7 +684,7 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
/*
* test_rel_for_autovac
*
- * Check whether a table needs to be vacuumed or analyzed. Add it to the
+ * Check whether a table needs to be vacuumed or analyzed. Add it to the
* appropriate output list if so.
*
* A table needs to be vacuumed if the number of dead tuples exceeds a
@@ -718,33 +715,37 @@ test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry,
List **vacuum_tables,
List **toast_table_ids)
{
- Relation rel;
- float4 reltuples; /* pg_class.reltuples */
+ Relation rel;
+ float4 reltuples; /* pg_class.reltuples */
+
/* constants from pg_autovacuum or GUC variables */
- int vac_base_thresh,
- anl_base_thresh;
- float4 vac_scale_factor,
- anl_scale_factor;
+ int vac_base_thresh,
+ anl_base_thresh;
+ float4 vac_scale_factor,
+ anl_scale_factor;
+
/* thresholds calculated from above constants */
- float4 vacthresh,
- anlthresh;
+ float4 vacthresh,
+ anlthresh;
+
/* number of vacuum (resp. analyze) tuples at this time */
- float4 vactuples,
- anltuples;
+ float4 vactuples,
+ anltuples;
+
/* cost-based vacuum delay parameters */
- int vac_cost_limit;
- int vac_cost_delay;
- bool dovacuum;
- bool doanalyze;
+ int vac_cost_limit;
+ int vac_cost_delay;
+ bool dovacuum;
+ bool doanalyze;
/* User disabled it in pg_autovacuum? */
if (avForm && !avForm->enabled)
return;
/*
- * Skip a table not found in stat hash. If it's not acted upon,
- * there's no need to vacuum it. (Note that database-level check
- * will take care of Xid wraparound.)
+ * Skip a table not found in stat hash. If it's not acted upon, there's
+ * no need to vacuum it. (Note that database-level check will take care
+ * of Xid wraparound.)
*/
if (!PointerIsValid(tabentry))
return;
@@ -805,9 +806,9 @@ test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry,
anlthresh = (float4) anl_base_thresh + anl_scale_factor * reltuples;
/*
- * Note that we don't need to take special consideration for stat
- * reset, because if that happens, the last vacuum and analyze counts
- * will be reset too.
+ * Note that we don't need to take special consideration for stat reset,
+ * because if that happens, the last vacuum and analyze counts will be
+ * reset too.
*/
elog(DEBUG3, "%s: vac: %.0f (threshold %.0f), anl: %.0f (threshold %.0f)",
@@ -863,27 +864,27 @@ test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry,
/*
* autovacuum_do_vac_analyze
- * Vacuum and/or analyze a list of tables; or all tables if relids = NIL
+ * Vacuum and/or analyze a list of tables; or all tables if relids = NIL
*/
static void
autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze,
bool freeze)
{
- VacuumStmt *vacstmt;
- MemoryContext old_cxt;
-
+ VacuumStmt *vacstmt;
+ MemoryContext old_cxt;
+
/*
* The node must survive transaction boundaries, so make sure we create it
* in a long-lived context
*/
old_cxt = MemoryContextSwitchTo(AutovacMemCxt);
-
+
vacstmt = makeNode(VacuumStmt);
/*
* Point QueryContext to the autovac memory context to fake out the
- * PreventTransactionChain check inside vacuum(). Note that this
- * is also why we palloc vacstmt instead of just using a local variable.
+ * PreventTransactionChain check inside vacuum(). Note that this is also
+ * why we palloc vacstmt instead of just using a local variable.
*/
QueryContext = CurrentMemoryContext;
@@ -904,8 +905,8 @@ autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze,
/*
* AutoVacuumingActive
- * Check GUC vars and report whether the autovacuum process should be
- * running.
+ * Check GUC vars and report whether the autovacuum process should be
+ * running.
*/
bool
AutoVacuumingActive(void)
@@ -918,7 +919,7 @@ AutoVacuumingActive(void)
/*
* autovac_init
- * This is called at postmaster initialization.
+ * This is called at postmaster initialization.
*
* Annoy the user if he got it wrong.
*/
@@ -933,6 +934,7 @@ autovac_init(void)
ereport(WARNING,
(errmsg("autovacuum not started because of misconfiguration"),
errhint("Enable options \"stats_start_collector\" and \"stats_row_level\".")));
+
/*
* Set the GUC var so we don't fork autovacuum uselessly, and also to
* help debugging.
@@ -943,7 +945,7 @@ autovac_init(void)
/*
* IsAutoVacuumProcess
- * Return whether this process is an autovacuum process.
+ * Return whether this process is an autovacuum process.
*/
bool
IsAutoVacuumProcess(void)
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
index ed1a7b2f27..78fecf4dd6 100644
--- a/src/backend/postmaster/bgwriter.c
+++ b/src/backend/postmaster/bgwriter.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.20 2005/09/12 22:20:16 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.21 2005/10/15 02:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -171,11 +171,11 @@ BackgroundWriterMain(void)
*
* Note: we deliberately ignore SIGTERM, because during a standard Unix
* system shutdown cycle, init will SIGTERM all processes at once. We
- * want to wait for the backends to exit, whereupon the postmaster
- * will tell us it's okay to shut down (via SIGUSR2).
+ * want to wait for the backends to exit, whereupon the postmaster will
+ * tell us it's okay to shut down (via SIGUSR2).
*
- * SIGUSR1 is presently unused; keep it spare in case someday we want
- * this process to participate in sinval messaging.
+ * SIGUSR1 is presently unused; keep it spare in case someday we want this
+ * process to participate in sinval messaging.
*/
pqsignal(SIGHUP, BgSigHupHandler); /* set flag to read config file */
pqsignal(SIGINT, ReqCheckpointHandler); /* request checkpoint */
@@ -203,15 +203,15 @@ BackgroundWriterMain(void)
#endif
/*
- * Initialize so that first time-driven checkpoint happens at the
- * correct time.
+ * Initialize so that first time-driven checkpoint happens at the correct
+ * time.
*/
last_checkpoint_time = time(NULL);
/*
- * Create a memory context that we will do all our work in. We do this
- * so that we can reset the context during error recovery and thereby
- * avoid possible memory leaks. Formerly this code just ran in
+ * Create a memory context that we will do all our work in. We do this so
+ * that we can reset the context during error recovery and thereby avoid
+ * possible memory leaks. Formerly this code just ran in
* TopMemoryContext, but resetting that would be a really bad idea.
*/
bgwriter_context = AllocSetContextCreate(TopMemoryContext,
@@ -258,8 +258,8 @@ BackgroundWriterMain(void)
}
/*
- * Now return to normal top-level context and clear ErrorContext
- * for next time.
+ * Now return to normal top-level context and clear ErrorContext for
+ * next time.
*/
MemoryContextSwitchTo(bgwriter_context);
FlushErrorState();
@@ -271,9 +271,9 @@ BackgroundWriterMain(void)
RESUME_INTERRUPTS();
/*
- * Sleep at least 1 second after any error. A write error is
- * likely to be repeated, and we don't want to be filling the
- * error logs as fast as we can.
+ * Sleep at least 1 second after any error. A write error is likely
+ * to be repeated, and we don't want to be filling the error logs as
+ * fast as we can.
*/
pg_usleep(1000000L);
}
@@ -329,8 +329,8 @@ BackgroundWriterMain(void)
}
/*
- * Do an unforced checkpoint if too much time has elapsed since
- * the last one.
+ * Do an unforced checkpoint if too much time has elapsed since the
+ * last one.
*/
now = time(NULL);
elapsed_secs = now - last_checkpoint_time;
@@ -346,8 +346,8 @@ BackgroundWriterMain(void)
/*
* We will warn if (a) too soon since last checkpoint (whatever
* caused it) and (b) somebody has set the ckpt_time_warn flag
- * since the last checkpoint start. Note in particular that
- * this implementation will not generate warnings caused by
+ * since the last checkpoint start. Note in particular that this
+ * implementation will not generate warnings caused by
* CheckPointTimeout < CheckPointWarning.
*/
if (BgWriterShmem->ckpt_time_warn &&
@@ -368,8 +368,7 @@ BackgroundWriterMain(void)
/*
* After any checkpoint, close all smgr files. This is so we
- * won't hang onto smgr references to deleted files
- * indefinitely.
+ * won't hang onto smgr references to deleted files indefinitely.
*/
smgrcloseall();
@@ -381,8 +380,8 @@ BackgroundWriterMain(void)
/*
* Note we record the checkpoint start time not end time as
- * last_checkpoint_time. This is so that time-driven
- * checkpoints happen at a predictable spacing.
+ * last_checkpoint_time. This is so that time-driven checkpoints
+ * happen at a predictable spacing.
*/
last_checkpoint_time = now;
}
@@ -390,13 +389,13 @@ BackgroundWriterMain(void)
BgBufferSync();
/*
- * Nap for the configured time, or sleep for 10 seconds if there
- * is no bgwriter activity configured.
+ * Nap for the configured time, or sleep for 10 seconds if there is no
+ * bgwriter activity configured.
*
- * On some platforms, signals won't interrupt the sleep. To ensure
- * we respond reasonably promptly when someone signals us, break
- * down the sleep into 1-second increments, and check for
- * interrupts after each nap.
+ * On some platforms, signals won't interrupt the sleep. To ensure we
+ * respond reasonably promptly when someone signals us, break down the
+ * sleep into 1-second increments, and check for interrupts after each
+ * nap.
*
* We absorb pending requests after each short sleep.
*/
@@ -437,13 +436,13 @@ bg_quickdie(SIGNAL_ARGS)
/*
* DO NOT proc_exit() -- we're here because shared memory may be
- * corrupted, so we don't want to try to clean up our transaction.
- * Just nail the windows shut and get out of town.
+ * corrupted, so we don't want to try to clean up our transaction. Just
+ * nail the windows shut and get out of town.
*
- * Note we do exit(1) not exit(0). This is to force the postmaster into
- * a system reset cycle if some idiot DBA sends a manual SIGQUIT to a
- * random backend. This is necessary precisely because we don't clean
- * up our shared memory state.
+ * Note we do exit(1) not exit(0). This is to force the postmaster into a
+ * system reset cycle if some idiot DBA sends a manual SIGQUIT to a random
+ * backend. This is necessary precisely because we don't clean up our
+ * shared memory state.
*/
exit(1);
}
@@ -485,8 +484,8 @@ BgWriterShmemSize(void)
Size size;
/*
- * Currently, the size of the requests[] array is arbitrarily set
- * equal to NBuffers. This may prove too large or small ...
+ * Currently, the size of the requests[] array is arbitrarily set equal to
+ * NBuffers. This may prove too large or small ...
*/
size = offsetof(BgWriterShmemStruct, requests);
size = add_size(size, mul_size(NBuffers, sizeof(BgWriterRequest)));
@@ -546,9 +545,8 @@ RequestCheckpoint(bool waitforit, bool warnontime)
CreateCheckPoint(false, true);
/*
- * After any checkpoint, close all smgr files. This is so we
- * won't hang onto smgr references to deleted files
- * indefinitely.
+ * After any checkpoint, close all smgr files. This is so we won't
+ * hang onto smgr references to deleted files indefinitely.
*/
smgrcloseall();
@@ -571,8 +569,8 @@ RequestCheckpoint(bool waitforit, bool warnontime)
"could not signal for checkpoint: %m");
/*
- * If requested, wait for completion. We detect completion according
- * to the algorithm given above.
+ * If requested, wait for completion. We detect completion according to
+ * the algorithm given above.
*/
if (waitforit)
{
@@ -585,13 +583,12 @@ RequestCheckpoint(bool waitforit, bool warnontime)
/*
* We are waiting for ckpt_done >= old_started, in a modulo sense.
- * This is a little tricky since we don't know the width or
- * signedness of sig_atomic_t. We make the lowest common
- * denominator assumption that it is only as wide as "char". This
- * means that this algorithm will cope correctly as long as we
- * don't sleep for more than 127 completed checkpoints. (If we
- * do, we will get another chance to exit after 128 more
- * checkpoints...)
+ * This is a little tricky since we don't know the width or signedness
+ * of sig_atomic_t. We make the lowest common denominator assumption
+ * that it is only as wide as "char". This means that this algorithm
+ * will cope correctly as long as we don't sleep for more than 127
+ * completed checkpoints. (If we do, we will get another chance to
+ * exit after 128 more checkpoints...)
*/
while (((signed char) (bgs->ckpt_done - old_started)) < 0)
{
@@ -666,17 +663,17 @@ AbsorbFsyncRequests(void)
return;
/*
- * We have to PANIC if we fail to absorb all the pending requests
- * (eg, because our hashtable runs out of memory). This is because
- * the system cannot run safely if we are unable to fsync what we
- * have been told to fsync. Fortunately, the hashtable is so small
- * that the problem is quite unlikely to arise in practice.
+ * We have to PANIC if we fail to absorb all the pending requests (eg,
+ * because our hashtable runs out of memory). This is because the system
+ * cannot run safely if we are unable to fsync what we have been told to
+ * fsync. Fortunately, the hashtable is so small that the problem is
+ * quite unlikely to arise in practice.
*/
START_CRIT_SECTION();
/*
- * We try to avoid holding the lock for a long time by copying the
- * request array.
+ * We try to avoid holding the lock for a long time by copying the request
+ * array.
*/
LWLockAcquire(BgWriterCommLock, LW_EXCLUSIVE);
diff --git a/src/backend/postmaster/fork_process.c b/src/backend/postmaster/fork_process.c
index 4064d7ccd4..54395b0654 100644
--- a/src/backend/postmaster/fork_process.c
+++ b/src/backend/postmaster/fork_process.c
@@ -1,13 +1,13 @@
/*
* fork_process.c
- * A simple wrapper on top of fork(). This does not handle the
- * EXEC_BACKEND case; it might be extended to do so, but it would be
- * considerably more complex.
+ * A simple wrapper on top of fork(). This does not handle the
+ * EXEC_BACKEND case; it might be extended to do so, but it would be
+ * considerably more complex.
*
* Copyright (c) 1996-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/fork_process.c,v 1.3 2005/03/16 00:02:39 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/fork_process.c,v 1.4 2005/10/15 02:49:23 momjian Exp $
*/
#include "postgres.h"
#include "postmaster/fork_process.h"
@@ -25,29 +25,29 @@
pid_t
fork_process(void)
{
- pid_t result;
+ pid_t result;
+
#ifdef LINUX_PROFILE
struct itimerval prof_itimer;
#endif
/*
- * Flush stdio channels just before fork, to avoid double-output
- * problems. Ideally we'd use fflush(NULL) here, but there are still a
- * few non-ANSI stdio libraries out there (like SunOS 4.1.x) that
- * coredump if we do. Presently stdout and stderr are the only stdio
- * output channels used by the postmaster, so fflush'ing them should
- * be sufficient.
+ * Flush stdio channels just before fork, to avoid double-output problems.
+ * Ideally we'd use fflush(NULL) here, but there are still a few non-ANSI
+ * stdio libraries out there (like SunOS 4.1.x) that coredump if we do.
+ * Presently stdout and stderr are the only stdio output channels used by
+ * the postmaster, so fflush'ing them should be sufficient.
*/
fflush(stdout);
fflush(stderr);
#ifdef LINUX_PROFILE
+
/*
- * Linux's fork() resets the profiling timer in the child process. If
- * we want to profile child processes then we need to save and restore
- * the timer setting. This is a waste of time if not profiling,
- * however, so only do it if commanded by specific -DLINUX_PROFILE
- * switch.
+ * Linux's fork() resets the profiling timer in the child process. If we
+ * want to profile child processes then we need to save and restore the
+ * timer setting. This is a waste of time if not profiling, however, so
+ * only do it if commanded by specific -DLINUX_PROFILE switch.
*/
getitimer(ITIMER_PROF, &prof_itimer);
#endif
@@ -81,4 +81,5 @@ fork_process(void)
return result;
}
-#endif /* ! WIN32 */
+
+#endif /* ! WIN32 */
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index 2f52053a2c..61019d7a5e 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -19,7 +19,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.17 2005/07/04 04:51:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.18 2005/10/15 02:49:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,11 +49,11 @@
* Timer definitions.
* ----------
*/
-#define PGARCH_AUTOWAKE_INTERVAL 60 /* How often to force a poll of
- * the archive status directory;
- * in seconds. */
-#define PGARCH_RESTART_INTERVAL 10 /* How often to attempt to restart
- * a failed archiver; in seconds. */
+#define PGARCH_AUTOWAKE_INTERVAL 60 /* How often to force a poll of the
+ * archive status directory; in
+ * seconds. */
+#define PGARCH_RESTART_INTERVAL 10 /* How often to attempt to restart a
+ * failed archiver; in seconds. */
/* ----------
* Archiver control info.
@@ -131,10 +131,9 @@ pgarch_start(void)
/*
* Do nothing if too soon since last archiver start. This is a safety
- * valve to protect against continuous respawn attempts if the
- * archiver is dying immediately at launch. Note that since we will be
- * re-called from the postmaster main loop, we will get another chance
- * later.
+ * valve to protect against continuous respawn attempts if the archiver is
+ * dying immediately at launch. Note that since we will be re-called from
+ * the postmaster main loop, we will get another chance later.
*/
curtime = time(NULL);
if ((unsigned int) (curtime - last_pgarch_start_time) <
@@ -292,9 +291,9 @@ pgarch_MainLoop(void)
/*
* We run the copy loop immediately upon entry, in case there are
- * unarchived files left over from a previous database run (or maybe
- * the archiver died unexpectedly). After that we wait for a signal
- * or timeout before doing more.
+ * unarchived files left over from a previous database run (or maybe the
+ * archiver died unexpectedly). After that we wait for a signal or
+ * timeout before doing more.
*/
wakened = true;
@@ -319,11 +318,11 @@ pgarch_MainLoop(void)
}
/*
- * There shouldn't be anything for the archiver to do except to
- * wait for a signal, ... however, the archiver exists to
- * protect our data, so she wakes up occasionally to allow
- * herself to be proactive. In particular this avoids getting
- * stuck if a signal arrives just before we sleep.
+ * There shouldn't be anything for the archiver to do except to wait
+ * for a signal, ... however, the archiver exists to protect our data,
+ * so she wakes up occasionally to allow herself to be proactive. In
+ * particular this avoids getting stuck if a signal arrives just
+ * before we sleep.
*/
if (!wakened)
{
@@ -349,9 +348,9 @@ pgarch_ArchiverCopyLoop(void)
/*
* loop through all xlogs with archive_status of .ready and archive
- * them...mostly we expect this to be a single file, though it is
- * possible some backend will add files onto the list of those that
- * need archiving while we are still copying earlier archives
+ * them...mostly we expect this to be a single file, though it is possible
+ * some backend will add files onto the list of those that need archiving
+ * while we are still copying earlier archives
*/
while (pgarch_readyXlog(xlog))
{
@@ -488,10 +487,10 @@ static bool
pgarch_readyXlog(char *xlog)
{
/*
- * open xlog status directory and read through list of xlogs that have
- * the .ready suffix, looking for earliest file. It is possible to
- * optimise this code, though only a single file is expected on the
- * vast majority of calls, so....
+ * open xlog status directory and read through list of xlogs that have the
+ * .ready suffix, looking for earliest file. It is possible to optimise
+ * this code, though only a single file is expected on the vast majority
+ * of calls, so....
*/
char XLogArchiveStatusDir[MAXPGPATH];
char newxlog[MAX_XFN_CHARS + 6 + 1];
@@ -504,8 +503,8 @@ pgarch_readyXlog(char *xlog)
if (rldir == NULL)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not open archive status directory \"%s\": %m",
- XLogArchiveStatusDir)));
+ errmsg("could not open archive status directory \"%s\": %m",
+ XLogArchiveStatusDir)));
while ((rlde = ReadDir(rldir, XLogArchiveStatusDir)) != NULL)
{
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index d03f812476..8d767a0b4c 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -13,7 +13,7 @@
*
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.109 2005/10/06 02:29:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.110 2005/10/15 02:49:23 momjian Exp $
* ----------
*/
#include "postgres.h"
@@ -66,19 +66,18 @@
* Timer definitions.
* ----------
*/
-#define PGSTAT_STAT_INTERVAL 500 /* How often to write the status
- * file; in milliseconds. */
+#define PGSTAT_STAT_INTERVAL 500 /* How often to write the status file;
+ * in milliseconds. */
-#define PGSTAT_DESTROY_DELAY 10000 /* How long to keep destroyed
- * objects known, to give delayed
- * UDP packets time to arrive; in
- * milliseconds. */
+#define PGSTAT_DESTROY_DELAY 10000 /* How long to keep destroyed objects
+ * known, to give delayed UDP packets
+ * time to arrive; in milliseconds. */
#define PGSTAT_DESTROY_COUNT (PGSTAT_DESTROY_DELAY / PGSTAT_STAT_INTERVAL)
-#define PGSTAT_RESTART_INTERVAL 60 /* How often to attempt to restart
- * a failed statistics collector;
- * in seconds. */
+#define PGSTAT_RESTART_INTERVAL 60 /* How often to attempt to restart a
+ * failed statistics collector; in
+ * seconds. */
/* ----------
* Amount of space reserved in pgstat_recvbuffer().
@@ -110,7 +109,7 @@ bool pgstat_collect_blocklevel = false;
* ----------
*/
NON_EXEC_STATIC int pgStatSock = -1;
-NON_EXEC_STATIC int pgStatPipe[2] = {-1,-1};
+NON_EXEC_STATIC int pgStatPipe[2] = {-1, -1};
static struct sockaddr_storage pgStatAddr;
static pid_t pgStatCollectorPid = 0;
@@ -127,15 +126,15 @@ static bool pgStatRunningInCollector = FALSE;
*/
typedef struct TabStatArray
{
- int tsa_alloc; /* num allocated */
- int tsa_used; /* num actually used */
+ int tsa_alloc; /* num allocated */
+ int tsa_used; /* num actually used */
PgStat_MsgTabstat **tsa_messages; /* the array itself */
} TabStatArray;
#define TABSTAT_QUANTUM 4 /* we alloc this many at a time */
-static TabStatArray RegularTabStat = { 0, 0, NULL };
-static TabStatArray SharedTabStat = { 0, 0, NULL };
+static TabStatArray RegularTabStat = {0, 0, NULL};
+static TabStatArray SharedTabStat = {0, 0, NULL};
static int pgStatXactCommit = 0;
static int pgStatXactRollback = 0;
@@ -266,12 +265,12 @@ pgstat_init(void)
}
/*
- * On some platforms, getaddrinfo_all() may return multiple addresses
- * only one of which will actually work (eg, both IPv6 and IPv4
- * addresses when kernel will reject IPv6). Worse, the failure may
- * occur at the bind() or perhaps even connect() stage. So we must
- * loop through the results till we find a working combination. We
- * will generate LOG messages, but no error, for bogus combinations.
+ * On some platforms, getaddrinfo_all() may return multiple addresses only
+ * one of which will actually work (eg, both IPv6 and IPv4 addresses when
+ * kernel will reject IPv6). Worse, the failure may occur at the bind()
+ * or perhaps even connect() stage. So we must loop through the results
+ * till we find a working combination. We will generate LOG messages, but
+ * no error, for bogus combinations.
*/
for (addr = addrs; addr; addr = addr->ai_next)
{
@@ -288,19 +287,19 @@ pgstat_init(void)
{
ereport(LOG,
(errcode_for_socket_access(),
- errmsg("could not create socket for statistics collector: %m")));
+ errmsg("could not create socket for statistics collector: %m")));
continue;
}
/*
- * Bind it to a kernel assigned port on localhost and get the
- * assigned port via getsockname().
+ * Bind it to a kernel assigned port on localhost and get the assigned
+ * port via getsockname().
*/
if (bind(pgStatSock, addr->ai_addr, addr->ai_addrlen) < 0)
{
ereport(LOG,
(errcode_for_socket_access(),
- errmsg("could not bind socket for statistics collector: %m")));
+ errmsg("could not bind socket for statistics collector: %m")));
closesocket(pgStatSock);
pgStatSock = -1;
continue;
@@ -318,26 +317,26 @@ pgstat_init(void)
}
/*
- * Connect the socket to its own address. This saves a few cycles
- * by not having to respecify the target address on every send.
- * This also provides a kernel-level check that only packets from
- * this same address will be received.
+ * Connect the socket to its own address. This saves a few cycles by
+ * not having to respecify the target address on every send. This also
+ * provides a kernel-level check that only packets from this same
+ * address will be received.
*/
if (connect(pgStatSock, (struct sockaddr *) & pgStatAddr, alen) < 0)
{
ereport(LOG,
(errcode_for_socket_access(),
- errmsg("could not connect socket for statistics collector: %m")));
+ errmsg("could not connect socket for statistics collector: %m")));
closesocket(pgStatSock);
pgStatSock = -1;
continue;
}
/*
- * Try to send and receive a one-byte test message on the socket.
- * This is to catch situations where the socket can be created but
- * will not actually pass data (for instance, because kernel
- * packet filtering rules prevent it).
+ * Try to send and receive a one-byte test message on the socket. This
+ * is to catch situations where the socket can be created but will not
+ * actually pass data (for instance, because kernel packet filtering
+ * rules prevent it).
*/
test_byte = TESTBYTEVAL;
if (send(pgStatSock, &test_byte, 1, 0) != 1)
@@ -351,9 +350,9 @@ pgstat_init(void)
}
/*
- * There could possibly be a little delay before the message can
- * be received. We arbitrarily allow up to half a second before
- * deciding it's broken.
+ * There could possibly be a little delay before the message can be
+ * received. We arbitrarily allow up to half a second before deciding
+ * it's broken.
*/
for (;;) /* need a loop to handle EINTR */
{
@@ -369,7 +368,7 @@ pgstat_init(void)
{
ereport(LOG,
(errcode_for_socket_access(),
- errmsg("select() failed in statistics collector: %m")));
+ errmsg("select() failed in statistics collector: %m")));
closesocket(pgStatSock);
pgStatSock = -1;
continue;
@@ -377,8 +376,8 @@ pgstat_init(void)
if (sel_res == 0 || !FD_ISSET(pgStatSock, &rset))
{
/*
- * This is the case we actually think is likely, so take pains
- * to give a specific message for it.
+ * This is the case we actually think is likely, so take pains to
+ * give a specific message for it.
*
* errno will not be set meaningfully here, so don't use it.
*/
@@ -421,10 +420,10 @@ pgstat_init(void)
goto startup_failed;
/*
- * Set the socket to non-blocking IO. This ensures that if the
- * collector falls behind (despite the buffering process), statistics
- * messages will be discarded; backends won't block waiting to send
- * messages to the collector.
+ * Set the socket to non-blocking IO. This ensures that if the collector
+ * falls behind (despite the buffering process), statistics messages will
+ * be discarded; backends won't block waiting to send messages to the
+ * collector.
*/
if (!pg_set_noblock(pgStatSock))
{
@@ -440,7 +439,7 @@ pgstat_init(void)
startup_failed:
ereport(LOG,
- (errmsg("disabling statistics collector for lack of working socket")));
+ (errmsg("disabling statistics collector for lack of working socket")));
if (addrs)
freeaddrinfo_all(hints.ai_family, addrs);
@@ -459,7 +458,7 @@ startup_failed:
/*
* pgstat_reset_all() -
*
- * Remove the stats file. This is used on server start if the
+ * Remove the stats file. This is used on server start if the
* stats_reset_on_server_start feature is enabled, or if WAL
* recovery is needed after a crash.
*/
@@ -560,11 +559,10 @@ pgstat_start(void)
return 0;
/*
- * Do nothing if too soon since last collector start. This is a
- * safety valve to protect against continuous respawn attempts if the
- * collector is dying immediately at launch. Note that since we will
- * be re-called from the postmaster main loop, we will get another
- * chance later.
+ * Do nothing if too soon since last collector start. This is a safety
+ * valve to protect against continuous respawn attempts if the collector
+ * is dying immediately at launch. Note that since we will be re-called
+ * from the postmaster main loop, we will get another chance later.
*/
curtime = time(NULL);
if ((unsigned int) (curtime - last_pgstat_start_time) <
@@ -650,7 +648,7 @@ pgstat_beterm(int pid)
/* ----------
* pgstat_report_autovac() -
*
- * Called from autovacuum.c to report startup of an autovacuum process.
+ * Called from autovacuum.c to report startup of an autovacuum process.
* We are called before InitPostgres is done, so can't rely on MyDatabaseId;
* the db OID must be passed in, instead.
* ----------
@@ -693,8 +691,8 @@ pgstat_bestart(void)
/*
* We may not have a MyProcPort (eg, if this is the autovacuum process).
- * For the moment, punt and don't send BESTART --- would be better to
- * work out a clean way of handling "unknown clientaddr".
+ * For the moment, punt and don't send BESTART --- would be better to work
+ * out a clean way of handling "unknown clientaddr".
*/
if (MyProcPort)
{
@@ -738,7 +736,7 @@ pgstat_report_vacuum(Oid tableoid, bool shared,
/* --------
* pgstat_report_analyze() -
*
- * Tell the collector about the table we just analyzed.
+ * Tell the collector about the table we just analyzed.
* --------
*/
void
@@ -898,8 +896,8 @@ pgstat_vacuum_tabstat(void)
return 0;
/*
- * If not done for this transaction, read the statistics collector
- * stats file into some hash tables.
+ * If not done for this transaction, read the statistics collector stats
+ * file into some hash tables.
*/
backend_read_statsfile();
@@ -926,8 +924,8 @@ pgstat_vacuum_tabstat(void)
while ((tabentry = (PgStat_StatTabEntry *) hash_seq_search(&hstat)) != NULL)
{
/*
- * Check if this relation is still alive by looking up it's
- * pg_class tuple in the system catalog cache.
+ * Check if this relation is still alive by looking up it's pg_class
+ * tuple in the system catalog cache.
*/
reltup = SearchSysCache(RELOID,
ObjectIdGetDatum(tabentry->tableid),
@@ -1072,7 +1070,7 @@ pgstat_reset_counters(void)
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to reset statistics counters")));
+ errmsg("must be superuser to reset statistics counters")));
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_RESETCOUNTER);
msg.m_databaseid = MyDatabaseId;
@@ -1150,7 +1148,7 @@ pgstat_initstats(PgStat_Info *stats, Relation rel)
{
Oid rel_id = rel->rd_id;
PgStat_TableEntry *useent;
- TabStatArray *tsarr;
+ TabStatArray *tsarr;
PgStat_MsgTabstat *tsmsg;
int mb;
int i;
@@ -1187,8 +1185,8 @@ pgstat_initstats(PgStat_Info *stats, Relation rel)
continue;
/*
- * Not found, but found a message buffer with an empty slot
- * instead. Fine, let's use this one.
+ * Not found, but found a message buffer with an empty slot instead.
+ * Fine, let's use this one.
*/
i = tsmsg->m_nentries++;
useent = &tsmsg->m_entry[i];
@@ -1234,9 +1232,9 @@ pgstat_count_xact_commit(void)
pgStatXactCommit++;
/*
- * If there was no relation activity yet, just make one existing
- * message buffer used without slots, causing the next report to tell
- * new xact-counters.
+ * If there was no relation activity yet, just make one existing message
+ * buffer used without slots, causing the next report to tell new
+ * xact-counters.
*/
if (RegularTabStat.tsa_alloc == 0)
more_tabstat_space(&RegularTabStat);
@@ -1266,9 +1264,9 @@ pgstat_count_xact_rollback(void)
pgStatXactRollback++;
/*
- * If there was no relation activity yet, just make one existing
- * message buffer used without slots, causing the next report to tell
- * new xact-counters.
+ * If there was no relation activity yet, just make one existing message
+ * buffer used without slots, causing the next report to tell new
+ * xact-counters.
*/
if (RegularTabStat.tsa_alloc == 0)
more_tabstat_space(&RegularTabStat);
@@ -1294,8 +1292,8 @@ PgStat_StatDBEntry *
pgstat_fetch_stat_dbentry(Oid dbid)
{
/*
- * If not done for this transaction, read the statistics collector
- * stats file into some hash tables.
+ * If not done for this transaction, read the statistics collector stats
+ * file into some hash tables.
*/
backend_read_statsfile();
@@ -1325,8 +1323,8 @@ pgstat_fetch_stat_tabentry(Oid relid)
PgStat_StatTabEntry *tabentry;
/*
- * If not done for this transaction, read the statistics collector
- * stats file into some hash tables.
+ * If not done for this transaction, read the statistics collector stats
+ * file into some hash tables.
*/
backend_read_statsfile();
@@ -1492,21 +1490,20 @@ PgstatBufferMain(int argc, char *argv[])
#endif
/*
- * Start a buffering process to read from the socket, so we have a
- * little more time to process incoming messages.
+ * Start a buffering process to read from the socket, so we have a little
+ * more time to process incoming messages.
*
- * NOTE: the process structure is: postmaster is parent of buffer process
- * is parent of collector process. This way, the buffer can detect
- * collector failure via SIGCHLD, whereas otherwise it wouldn't notice
- * collector failure until it tried to write on the pipe. That would
- * mean that after the postmaster started a new collector, we'd have
- * two buffer processes competing to read from the UDP socket --- not
- * good.
+ * NOTE: the process structure is: postmaster is parent of buffer process is
+ * parent of collector process. This way, the buffer can detect collector
+ * failure via SIGCHLD, whereas otherwise it wouldn't notice collector
+ * failure until it tried to write on the pipe. That would mean that
+ * after the postmaster started a new collector, we'd have two buffer
+ * processes competing to read from the UDP socket --- not good.
*/
if (pgpipe(pgStatPipe) < 0)
ereport(ERROR,
(errcode_for_socket_access(),
- errmsg("could not create pipe for statistics buffer: %m")));
+ errmsg("could not create pipe for statistics buffer: %m")));
/* child becomes collector process */
#ifdef EXEC_BACKEND
@@ -1561,10 +1558,10 @@ PgstatCollectorMain(int argc, char *argv[])
MyProcPid = getpid(); /* reset MyProcPid */
/*
- * Reset signal handling. With the exception of restoring default
- * SIGCHLD and SIGQUIT handling, this is a no-op in the
- * non-EXEC_BACKEND case because we'll have inherited these settings
- * from the buffer process; but it's not a no-op for EXEC_BACKEND.
+ * Reset signal handling. With the exception of restoring default SIGCHLD
+ * and SIGQUIT handling, this is a no-op in the non-EXEC_BACKEND case
+ * because we'll have inherited these settings from the buffer process;
+ * but it's not a no-op for EXEC_BACKEND.
*/
pqsignal(SIGHUP, SIG_IGN);
pqsignal(SIGINT, SIG_IGN);
@@ -1607,8 +1604,8 @@ PgstatCollectorMain(int argc, char *argv[])
need_statwrite = TRUE;
/*
- * Read in an existing statistics stats file or initialize the stats
- * to zero.
+ * Read in an existing statistics stats file or initialize the stats to
+ * zero.
*/
pgStatRunningInCollector = TRUE;
pgstat_read_statsfile(&pgStatDBHash, InvalidOid, NULL, NULL);
@@ -1638,9 +1635,9 @@ PgstatCollectorMain(int argc, char *argv[])
for (;;)
{
/*
- * If we need to write the status file again (there have been
- * changes in the statistics since we wrote it last) calculate the
- * timeout until we have to do so.
+ * If we need to write the status file again (there have been changes
+ * in the statistics since we wrote it last) calculate the timeout
+ * until we have to do so.
*/
if (need_statwrite)
{
@@ -1684,7 +1681,7 @@ PgstatCollectorMain(int argc, char *argv[])
continue;
ereport(ERROR,
(errcode_for_socket_access(),
- errmsg("select() failed in statistics collector: %m")));
+ errmsg("select() failed in statistics collector: %m")));
}
/*
@@ -1706,10 +1703,10 @@ PgstatCollectorMain(int argc, char *argv[])
{
/*
* We may need to issue multiple read calls in case the buffer
- * process didn't write the message in a single write, which
- * is possible since it dumps its buffer bytewise. In any
- * case, we'd need two reads since we don't know the message
- * length initially.
+ * process didn't write the message in a single write, which is
+ * possible since it dumps its buffer bytewise. In any case, we'd
+ * need two reads since we don't know the message length
+ * initially.
*/
int nread = 0;
int targetlen = sizeof(PgStat_MsgHdr); /* initial */
@@ -1742,25 +1739,24 @@ PgstatCollectorMain(int argc, char *argv[])
{
/*
* Bogus message length implies that we got out of
- * sync with the buffer process somehow. Abort so
- * that we can restart both processes.
+ * sync with the buffer process somehow. Abort so that
+ * we can restart both processes.
*/
ereport(ERROR,
- (errmsg("invalid statistics message length")));
+ (errmsg("invalid statistics message length")));
}
}
}
/*
- * EOF on the pipe implies that the buffer process exited.
- * Fall out of outer loop.
+ * EOF on the pipe implies that the buffer process exited. Fall
+ * out of outer loop.
*/
if (pipeEOF)
break;
/*
- * Distribute the message to the specific function handling
- * it.
+ * Distribute the message to the specific function handling it.
*/
switch (msg.msg_hdr.m_type)
{
@@ -1818,8 +1814,8 @@ PgstatCollectorMain(int argc, char *argv[])
pgStatNumMessages++;
/*
- * If this is the first message after we wrote the stats file
- * the last time, setup the timeout that it'd be written.
+ * If this is the first message after we wrote the stats file the
+ * last time, setup the timeout that it'd be written.
*/
if (!need_statwrite)
{
@@ -1832,20 +1828,20 @@ PgstatCollectorMain(int argc, char *argv[])
}
/*
- * Note that we do NOT check for postmaster exit inside the loop;
- * only EOF on the buffer pipe causes us to fall out. This
- * ensures we don't exit prematurely if there are still a few
- * messages in the buffer or pipe at postmaster shutdown.
+ * Note that we do NOT check for postmaster exit inside the loop; only
+ * EOF on the buffer pipe causes us to fall out. This ensures we
+ * don't exit prematurely if there are still a few messages in the
+ * buffer or pipe at postmaster shutdown.
*/
}
/*
- * Okay, we saw EOF on the buffer pipe, so there are no more messages
- * to process. If the buffer process quit because of postmaster
- * shutdown, we want to save the final stats to reuse at next startup.
- * But if the buffer process failed, it seems best not to (there may
- * even now be a new collector firing up, and we don't want it to read
- * a partially-rewritten stats file).
+ * Okay, we saw EOF on the buffer pipe, so there are no more messages to
+ * process. If the buffer process quit because of postmaster shutdown, we
+ * want to save the final stats to reuse at next startup. But if the
+ * buffer process failed, it seems best not to (there may even now be a
+ * new collector firing up, and we don't want it to read a
+ * partially-rewritten stats file).
*/
if (!PostmasterIsAlive(false))
pgstat_write_statsfile();
@@ -1887,18 +1883,18 @@ pgstat_recvbuffer(void)
set_ps_display("");
/*
- * We want to die if our child collector process does. There are two
- * ways we might notice that it has died: receive SIGCHLD, or get a
- * write failure on the pipe leading to the child. We can set SIGPIPE
- * to kill us here. Our SIGCHLD handler was already set up before we
- * forked (must do it that way, else it's a race condition).
+ * We want to die if our child collector process does. There are two ways
+ * we might notice that it has died: receive SIGCHLD, or get a write
+ * failure on the pipe leading to the child. We can set SIGPIPE to kill
+ * us here. Our SIGCHLD handler was already set up before we forked (must
+ * do it that way, else it's a race condition).
*/
pqsignal(SIGPIPE, SIG_DFL);
PG_SETMASK(&UnBlockSig);
/*
- * Set the write pipe to nonblock mode, so that we cannot block when
- * the collector falls behind.
+ * Set the write pipe to nonblock mode, so that we cannot block when the
+ * collector falls behind.
*/
if (!pg_set_noblock(writePipe))
ereport(ERROR,
@@ -1951,9 +1947,9 @@ pgstat_recvbuffer(void)
}
/*
- * Wait for some work to do; but not for more than 10 seconds.
- * (This determines how quickly we will shut down after an
- * ungraceful postmaster termination; so it needn't be very fast.)
+ * Wait for some work to do; but not for more than 10 seconds. (This
+ * determines how quickly we will shut down after an ungraceful
+ * postmaster termination; so it needn't be very fast.)
*/
timeout.tv_sec = 10;
timeout.tv_usec = 0;
@@ -1979,7 +1975,7 @@ pgstat_recvbuffer(void)
if (len < 0)
ereport(ERROR,
(errcode_for_socket_access(),
- errmsg("could not read statistics message: %m")));
+ errmsg("could not read statistics message: %m")));
/*
* We ignore messages that are smaller than our common header
@@ -2020,14 +2016,14 @@ pgstat_recvbuffer(void)
* If the collector is ready to receive, write some data into his
* pipe. We may or may not be able to write all that we have.
*
- * NOTE: if what we have is less than PIPE_BUF bytes but more than
- * the space available in the pipe buffer, most kernels will
- * refuse to write any of it, and will return EAGAIN. This means
- * we will busy-loop until the situation changes (either because
- * the collector caught up, or because more data arrives so that
- * we have more than PIPE_BUF bytes buffered). This is not good,
- * but is there any way around it? We have no way to tell when
- * the collector has caught up...
+ * NOTE: if what we have is less than PIPE_BUF bytes but more than the
+ * space available in the pipe buffer, most kernels will refuse to
+ * write any of it, and will return EAGAIN. This means we will
+ * busy-loop until the situation changes (either because the collector
+ * caught up, or because more data arrives so that we have more than
+ * PIPE_BUF bytes buffered). This is not good, but is there any way
+ * around it? We have no way to tell when the collector has caught
+ * up...
*/
if (FD_ISSET(writePipe, &wfds))
{
@@ -2042,7 +2038,7 @@ pgstat_recvbuffer(void)
continue; /* not enough space in pipe */
ereport(ERROR,
(errcode_for_socket_access(),
- errmsg("could not write to statistics collector pipe: %m")));
+ errmsg("could not write to statistics collector pipe: %m")));
}
/* NB: len < xfr is okay */
msg_send += len;
@@ -2052,15 +2048,15 @@ pgstat_recvbuffer(void)
}
/*
- * Make sure we forwarded all messages before we check for
- * postmaster termination.
+ * Make sure we forwarded all messages before we check for postmaster
+ * termination.
*/
if (msg_have != 0 || FD_ISSET(pgStatSock, &rfds))
continue;
/*
- * If the postmaster has terminated, we die too. (This is no
- * longer the normal exit path, however.)
+ * If the postmaster has terminated, we die too. (This is no longer
+ * the normal exit path, however.)
*/
if (!PostmasterIsAlive(true))
exit(0);
@@ -2072,9 +2068,9 @@ static void
pgstat_exit(SIGNAL_ARGS)
{
/*
- * For now, we just nail the doors shut and get out of town. It might
- * be cleaner to allow any pending messages to be sent, but that
- * creates a tradeoff against speed of exit.
+ * For now, we just nail the doors shut and get out of town. It might be
+ * cleaner to allow any pending messages to be sent, but that creates a
+ * tradeoff against speed of exit.
*/
/*
@@ -2115,7 +2111,7 @@ pgstat_add_backend(PgStat_MsgHdr *msg)
if (msg->m_backendid < 1 || msg->m_backendid > MaxBackends)
{
ereport(LOG,
- (errmsg("invalid server process ID %d", msg->m_backendid)));
+ (errmsg("invalid server process ID %d", msg->m_backendid)));
return -1;
}
@@ -2125,20 +2121,20 @@ pgstat_add_backend(PgStat_MsgHdr *msg)
beentry = &pgStatBeTable[msg->m_backendid - 1];
/*
- * If the slot contains the PID of this backend, everything is
- * fine and we have nothing to do. Note that all the slots are
- * zero'd out when the collector is started. We assume that a slot
- * is "empty" iff procpid == 0.
+ * If the slot contains the PID of this backend, everything is fine and we
+ * have nothing to do. Note that all the slots are zero'd out when the
+ * collector is started. We assume that a slot is "empty" iff procpid ==
+ * 0.
*/
if (beentry->procpid > 0 && beentry->procpid == msg->m_procpid)
return 0;
/*
- * Lookup if this backend is known to be dead. This can be caused due
- * to messages arriving in the wrong order - e.g. postmaster's BETERM
- * message might have arrived before we received all the backends
- * stats messages, or even a new backend with the same backendid was
- * faster in sending his BESTART.
+ * Lookup if this backend is known to be dead. This can be caused due to
+ * messages arriving in the wrong order - e.g. postmaster's BETERM message
+ * might have arrived before we received all the backends stats messages,
+ * or even a new backend with the same backendid was faster in sending his
+ * BESTART.
*
* If the backend is known to be dead, we ignore this add.
*/
@@ -2149,8 +2145,8 @@ pgstat_add_backend(PgStat_MsgHdr *msg)
return 1;
/*
- * Backend isn't known to be dead. If it's slot is currently used, we
- * have to kick out the old backend.
+ * Backend isn't known to be dead. If it's slot is currently used, we have
+ * to kick out the old backend.
*/
if (beentry->procpid > 0)
pgstat_sub_backend(beentry->procpid);
@@ -2165,12 +2161,11 @@ pgstat_add_backend(PgStat_MsgHdr *msg)
beentry->activity[0] = '\0';
/*
- * We can't initialize the rest of the data in this slot until we
- * see the BESTART message. Therefore, we set the database and
- * user to sentinel values, to indicate "undefined". There is no
- * easy way to do this for the client address, so make sure to
- * check that the database or user are defined before accessing
- * the client address.
+ * We can't initialize the rest of the data in this slot until we see the
+ * BESTART message. Therefore, we set the database and user to sentinel
+ * values, to indicate "undefined". There is no easy way to do this for
+ * the client address, so make sure to check that the database or user are
+ * defined before accessing the client address.
*/
beentry->userid = InvalidOid;
beentry->databaseid = InvalidOid;
@@ -2187,8 +2182,8 @@ static PgStat_StatDBEntry *
pgstat_get_db_entry(Oid databaseid, bool create)
{
PgStat_StatDBEntry *result;
- bool found;
- HASHACTION action = (create ? HASH_ENTER : HASH_FIND);
+ bool found;
+ HASHACTION action = (create ? HASH_ENTER : HASH_FIND);
/* Lookup or create the hash table entry for this database */
result = (PgStat_StatDBEntry *) hash_search(pgStatDBHash,
@@ -2216,9 +2211,9 @@ pgstat_get_db_entry(Oid databaseid, bool create)
hash_ctl.entrysize = sizeof(PgStat_StatTabEntry);
hash_ctl.hash = oid_hash;
result->tables = hash_create("Per-database table",
- PGSTAT_TAB_HASH_SIZE,
- &hash_ctl,
- HASH_ELEM | HASH_FUNCTION);
+ PGSTAT_TAB_HASH_SIZE,
+ &hash_ctl,
+ HASH_ELEM | HASH_FUNCTION);
}
return result;
@@ -2238,22 +2233,21 @@ pgstat_sub_backend(int procpid)
bool found;
/*
- * Search in the known-backends table for the slot containing this
- * PID.
+ * Search in the known-backends table for the slot containing this PID.
*/
for (i = 0; i < MaxBackends; i++)
{
if (pgStatBeTable[i].procpid == procpid)
{
/*
- * That's him. Add an entry to the known to be dead backends.
- * Due to possible misorder in the arrival of UDP packets it's
- * possible that even if we know the backend is dead, there
- * could still be messages queued that arrive later. Those
- * messages must not cause our number of backends statistics
- * to get screwed up, so we remember for a couple of seconds
- * that this PID is dead and ignore them (only the counting of
- * backends, not the table access stats they sent).
+ * That's him. Add an entry to the known to be dead backends. Due
+ * to possible misorder in the arrival of UDP packets it's
+ * possible that even if we know the backend is dead, there could
+ * still be messages queued that arrive later. Those messages must
+ * not cause our number of backends statistics to get screwed up,
+ * so we remember for a couple of seconds that this PID is dead
+ * and ignore them (only the counting of backends, not the table
+ * access stats they sent).
*/
deadbe = (PgStat_StatBeDead *) hash_search(pgStatBeDead,
(void *) &procpid,
@@ -2275,8 +2269,8 @@ pgstat_sub_backend(int procpid)
}
/*
- * No big problem if not found. This can happen if UDP messages arrive
- * out of order here.
+ * No big problem if not found. This can happen if UDP messages arrive out
+ * of order here.
*/
}
@@ -2307,8 +2301,8 @@ pgstat_write_statsfile(void)
{
ereport(LOG,
(errcode_for_file_access(),
- errmsg("could not open temporary statistics file \"%s\": %m",
- PGSTAT_STAT_TMPFILE)));
+ errmsg("could not open temporary statistics file \"%s\": %m",
+ PGSTAT_STAT_TMPFILE)));
return;
}
@@ -2325,8 +2319,8 @@ pgstat_write_statsfile(void)
while ((dbentry = (PgStat_StatDBEntry *) hash_seq_search(&hstat)) != NULL)
{
/*
- * If this database is marked destroyed, count down and do so if
- * it reaches 0.
+ * If this database is marked destroyed, count down and do so if it
+ * reaches 0.
*/
if (dbentry->destroy > 0)
{
@@ -2362,8 +2356,8 @@ pgstat_write_statsfile(void)
while ((tabentry = (PgStat_StatTabEntry *) hash_seq_search(&tstat)) != NULL)
{
/*
- * If table entry marked for destruction, same as above for
- * the database entry.
+ * If table entry marked for destruction, same as above for the
+ * database entry.
*/
if (tabentry->destroy > 0)
{
@@ -2384,8 +2378,8 @@ pgstat_write_statsfile(void)
}
/*
- * At least we think this is still a live table. Print its
- * access stats.
+ * At least we think this is still a live table. Print its access
+ * stats.
*/
fputc('T', fpout);
fwrite(tabentry, sizeof(PgStat_StatTabEntry), 1, fpout);
@@ -2422,8 +2416,8 @@ pgstat_write_statsfile(void)
{
ereport(LOG,
(errcode_for_file_access(),
- errmsg("could not close temporary statistics file \"%s\": %m",
- PGSTAT_STAT_TMPFILE)));
+ errmsg("could not close temporary statistics file \"%s\": %m",
+ PGSTAT_STAT_TMPFILE)));
}
else
{
@@ -2443,8 +2437,7 @@ pgstat_write_statsfile(void)
while ((deadbe = (PgStat_StatBeDead *) hash_seq_search(&hstat)) != NULL)
{
/*
- * Count down the destroy delay and remove entries where it
- * reaches 0.
+ * Count down the destroy delay and remove entries where it reaches 0.
*/
if (--(deadbe->destroy) <= 0)
{
@@ -2453,8 +2446,8 @@ pgstat_write_statsfile(void)
HASH_REMOVE, NULL) == NULL)
{
ereport(ERROR,
- (errmsg("dead-server-process hash table corrupted "
- "during cleanup --- abort")));
+ (errmsg("dead-server-process hash table corrupted "
+ "during cleanup --- abort")));
}
}
}
@@ -2491,7 +2484,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
/*
* If running in the collector or the autovacuum process, we use the
- * DynaHashCxt memory context. If running in a backend, we use the
+ * DynaHashCxt memory context. If running in a backend, we use the
* TopTransactionContext instead, so the caller must only know the last
* XactId when this call happened to know if his tables are still valid or
* already gone!
@@ -2525,8 +2518,8 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
HASH_ELEM | HASH_FUNCTION | mcxt_flags);
/*
- * Initialize the number of known backends to zero, just in case we do
- * a silent error return below.
+ * Initialize the number of known backends to zero, just in case we do a
+ * silent error return below.
*/
if (numbackends != NULL)
*numbackends = 0;
@@ -2534,9 +2527,9 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
*betab = NULL;
/*
- * Try to open the status file. If it doesn't exist, the backends
- * simply return zero for anything and the collector simply starts
- * from scratch with empty counters.
+ * Try to open the status file. If it doesn't exist, the backends simply
+ * return zero for anything and the collector simply starts from scratch
+ * with empty counters.
*/
if ((fpin = AllocateFile(PGSTAT_STAT_FILENAME, PG_BINARY_R)) == NULL)
return;
@@ -2562,8 +2555,8 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
{
/*
* 'D' A PgStat_StatDBEntry struct describing a database
- * follows. Subsequently, zero to many 'T' entries will
- * follow until a 'd' is encountered.
+ * follows. Subsequently, zero to many 'T' entries will follow
+ * until a 'd' is encountered.
*/
case 'D':
if (fread(&dbbuf, 1, sizeof(dbbuf), fpin) != sizeof(dbbuf))
@@ -2577,7 +2570,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
* Add to the DB hash
*/
dbentry = (PgStat_StatDBEntry *) hash_search(*dbhash,
- (void *) &dbbuf.databaseid,
+ (void *) &dbbuf.databaseid,
HASH_ENTER,
&found);
if (found)
@@ -2600,7 +2593,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
{
if (dbbuf.databaseid != onlydb &&
dbbuf.databaseid != InvalidOid)
- break;
+ break;
}
memset(&hash_ctl, 0, sizeof(hash_ctl));
@@ -2611,11 +2604,11 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
dbentry->tables = hash_create("Per-database table",
PGSTAT_TAB_HASH_SIZE,
&hash_ctl,
- HASH_ELEM | HASH_FUNCTION | mcxt_flags);
+ HASH_ELEM | HASH_FUNCTION | mcxt_flags);
/*
- * Arrange that following 'T's add entries to this
- * databases tables hash table.
+ * Arrange that following 'T's add entries to this databases
+ * tables hash table.
*/
tabhash = dbentry->tables;
break;
@@ -2645,8 +2638,8 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
break;
tabentry = (PgStat_StatTabEntry *) hash_search(tabhash,
- (void *) &tabbuf.tableid,
- HASH_ENTER, &found);
+ (void *) &tabbuf.tableid,
+ HASH_ENTER, &found);
if (found)
{
@@ -2684,7 +2677,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
else
*betab = (PgStat_StatBeEntry *)
MemoryContextAlloc(use_mcxt,
- sizeof(PgStat_StatBeEntry) * maxbackends);
+ sizeof(PgStat_StatBeEntry) * maxbackends);
break;
/*
@@ -2811,9 +2804,9 @@ pgstat_recv_bestart(PgStat_MsgBestart *msg, int len)
PgStat_StatBeEntry *entry;
/*
- * If the backend is known dead, we ignore the message -- we don't
- * want to update the backend entry's state since this BESTART
- * message refers to an old, dead backend
+ * If the backend is known dead, we ignore the message -- we don't want to
+ * update the backend entry's state since this BESTART message refers to
+ * an old, dead backend
*/
if (pgstat_add_backend(&msg->m_hdr) != 0)
return;
@@ -2840,7 +2833,7 @@ pgstat_recv_beterm(PgStat_MsgBeterm *msg, int len)
/* ----------
* pgstat_recv_autovac() -
*
- * Process an autovacuum signalling message.
+ * Process an autovacuum signalling message.
* ----------
*/
static void
@@ -2851,10 +2844,9 @@ pgstat_recv_autovac(PgStat_MsgAutovacStart *msg, int len)
/*
* Lookup the database in the hashtable. Don't create the entry if it
* doesn't exist, because autovacuum may be processing a template
- * database. If this isn't the case, the database is most likely to
- * have an entry already. (If it doesn't, not much harm is done
- * anyway -- it'll get created as soon as somebody actually uses
- * the database.)
+ * database. If this isn't the case, the database is most likely to have
+ * an entry already. (If it doesn't, not much harm is done anyway --
+ * it'll get created as soon as somebody actually uses the database.)
*/
dbentry = pgstat_get_db_entry(msg->m_databaseid, false);
if (dbentry == NULL)
@@ -2869,7 +2861,7 @@ pgstat_recv_autovac(PgStat_MsgAutovacStart *msg, int len)
/* ----------
* pgstat_recv_vacuum() -
*
- * Process a VACUUM message.
+ * Process a VACUUM message.
* ----------
*/
static void
@@ -2881,10 +2873,10 @@ pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len)
bool create;
/*
- * If we don't know about the database, ignore the message, because it
- * may be autovacuum processing a template database. But if the message
- * is for database InvalidOid, don't ignore it, because we are getting
- * a message from vacuuming a shared relation.
+ * If we don't know about the database, ignore the message, because it may
+ * be autovacuum processing a template database. But if the message is
+ * for database InvalidOid, don't ignore it, because we are getting a
+ * message from vacuuming a shared relation.
*/
create = (msg->m_databaseid == InvalidOid);
@@ -2933,7 +2925,7 @@ pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len)
/* ----------
* pgstat_recv_analyze() -
*
- * Process an ANALYZE message.
+ * Process an ANALYZE message.
* ----------
*/
static void
@@ -2944,9 +2936,9 @@ pgstat_recv_analyze(PgStat_MsgAnalyze *msg, int len)
bool found;
/*
- * Note that we do create the database entry here, as opposed to what
- * we do on AutovacStart and Vacuum messages. This is because
- * autovacuum never executes ANALYZE on template databases.
+ * Note that we do create the database entry here, as opposed to what we
+ * do on AutovacStart and Vacuum messages. This is because autovacuum
+ * never executes ANALYZE on template databases.
*/
dbentry = pgstat_get_db_entry(msg->m_databaseid, true);
@@ -2995,9 +2987,8 @@ pgstat_recv_activity(PgStat_MsgActivity *msg, int len)
PgStat_StatBeEntry *entry;
/*
- * Here we check explicitly for 0 return, since we don't want to
- * mangle the activity of an active backend by a delayed packet from a
- * dead one.
+ * Here we check explicitly for 0 return, since we don't want to mangle
+ * the activity of an active backend by a delayed packet from a dead one.
*/
if (pgstat_add_backend(&msg->m_hdr) != 0)
return;
@@ -3034,8 +3025,8 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len)
dbentry = pgstat_get_db_entry(msg->m_databaseid, true);
/*
- * If the database is marked for destroy, this is a delayed UDP packet
- * and not worth being counted.
+ * If the database is marked for destroy, this is a delayed UDP packet and
+ * not worth being counted.
*/
if (dbentry->destroy > 0)
return;
@@ -3049,14 +3040,14 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len)
for (i = 0; i < msg->m_nentries; i++)
{
tabentry = (PgStat_StatTabEntry *) hash_search(dbentry->tables,
- (void *) &(tabmsg[i].t_id),
- HASH_ENTER, &found);
+ (void *) &(tabmsg[i].t_id),
+ HASH_ENTER, &found);
if (!found)
{
/*
- * If it's a new table entry, initialize counters to the
- * values we just got.
+ * If it's a new table entry, initialize counters to the values we
+ * just got.
*/
tabentry->numscans = tabmsg[i].t_numscans;
tabentry->tuples_returned = tabmsg[i].t_tuples_returned;
@@ -3064,7 +3055,7 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len)
tabentry->tuples_inserted = tabmsg[i].t_tuples_inserted;
tabentry->tuples_updated = tabmsg[i].t_tuples_updated;
tabentry->tuples_deleted = tabmsg[i].t_tuples_deleted;
-
+
tabentry->n_live_tuples = tabmsg[i].t_tuples_inserted;
tabentry->n_dead_tuples = tabmsg[i].t_tuples_updated +
tabmsg[i].t_tuples_deleted;
@@ -3132,8 +3123,8 @@ pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len)
return;
/*
- * If the database is marked for destroy, this is a delayed UDP packet
- * and the tables will go away at DB destruction.
+ * If the database is marked for destroy, this is a delayed UDP packet and
+ * the tables will go away at DB destruction.
*/
if (dbentry->destroy > 0)
return;
@@ -3144,7 +3135,7 @@ pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len)
for (i = 0; i < msg->m_nentries; i++)
{
tabentry = (PgStat_StatTabEntry *) hash_search(dbentry->tables,
- (void *) &(msg->m_tableid[i]),
+ (void *) &(msg->m_tableid[i]),
HASH_FIND, NULL);
if (tabentry)
tabentry->destroy = PGSTAT_DESTROY_COUNT;
@@ -3209,8 +3200,8 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len)
return;
/*
- * We simply throw away all the database's table entries by
- * recreating a new hash table for them.
+ * We simply throw away all the database's table entries by recreating a
+ * new hash table for them.
*/
if (dbentry->tables != NULL)
hash_destroy(dbentry->tables);
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index aee26add55..fd7b27193c 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.468 2005/09/22 15:33:35 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.469 2005/10/15 02:49:23 momjian Exp $
*
* NOTES
*
@@ -301,9 +301,10 @@ static pid_t internal_forkexec(int argc, char *argv[], Port *port);
#ifdef WIN32
typedef struct
{
- SOCKET origsocket; /* Original socket value, or -1 if not a socket */
+ SOCKET origsocket; /* Original socket value, or -1 if not a
+ * socket */
WSAPROTOCOL_INFO wsainfo;
-} InheritableSocket;
+} InheritableSocket;
#else
typedef int InheritableSocket;
#endif
@@ -315,51 +316,51 @@ typedef struct LWLock LWLock; /* ugly kluge */
*/
typedef struct
{
- Port port;
+ Port port;
InheritableSocket portsocket;
- char DataDir[MAXPGPATH];
- int ListenSocket[MAXLISTEN];
- long MyCancelKey;
+ char DataDir[MAXPGPATH];
+ int ListenSocket[MAXLISTEN];
+ long MyCancelKey;
unsigned long UsedShmemSegID;
- void *UsedShmemSegAddr;
- slock_t *ShmemLock;
- slock_t *ShmemIndexLock;
+ void *UsedShmemSegAddr;
+ slock_t *ShmemLock;
+ slock_t *ShmemIndexLock;
VariableCache ShmemVariableCache;
- void *ShmemIndexAlloc;
- Backend *ShmemBackendArray;
- LWLock *LWLockArray;
- slock_t *ProcStructLock;
+ void *ShmemIndexAlloc;
+ Backend *ShmemBackendArray;
+ LWLock *LWLockArray;
+ slock_t *ProcStructLock;
InheritableSocket pgStatSock;
InheritableSocket pgStatPipe0;
InheritableSocket pgStatPipe1;
- pid_t PostmasterPid;
+ pid_t PostmasterPid;
TimestampTz PgStartTime;
#ifdef WIN32
- HANDLE PostmasterHandle;
- HANDLE initial_signal_pipe;
- HANDLE syslogPipe[2];
+ HANDLE PostmasterHandle;
+ HANDLE initial_signal_pipe;
+ HANDLE syslogPipe[2];
#else
- int syslogPipe[2];
+ int syslogPipe[2];
#endif
- char my_exec_path[MAXPGPATH];
- char pkglib_path[MAXPGPATH];
- char ExtraOptions[MAXPGPATH];
- char lc_collate[LOCALE_NAME_BUFLEN];
- char lc_ctype[LOCALE_NAME_BUFLEN];
-} BackendParameters;
+ char my_exec_path[MAXPGPATH];
+ char pkglib_path[MAXPGPATH];
+ char ExtraOptions[MAXPGPATH];
+ char lc_collate[LOCALE_NAME_BUFLEN];
+ char lc_ctype[LOCALE_NAME_BUFLEN];
+} BackendParameters;
static void read_backend_variables(char *id, Port *port);
-static void restore_backend_variables(BackendParameters *param, Port *port);
+static void restore_backend_variables(BackendParameters * param, Port *port);
+
#ifndef WIN32
-static bool save_backend_variables(BackendParameters *param, Port *port);
+static bool save_backend_variables(BackendParameters * param, Port *port);
#else
-static bool save_backend_variables(BackendParameters *param, Port *port,
- HANDLE childProcess, pid_t childPid);
+static bool save_backend_variables(BackendParameters * param, Port *port,
+ HANDLE childProcess, pid_t childPid);
#endif
static void ShmemBackendArrayAdd(Backend *bn);
static void ShmemBackendArrayRemove(pid_t pid);
-
#endif /* EXEC_BACKEND */
#define StartupDataBase() StartChildProcess(BS_XLOG_STARTUP)
@@ -378,7 +379,7 @@ PostmasterMain(int argc, char *argv[])
int i;
/* This will call exit() if strdup() fails. */
- progname = get_progname(argv[0]);
+ progname = get_progname(argv[0]);
MyProcPid = PostmasterPid = getpid();
@@ -408,8 +409,7 @@ PostmasterMain(int argc, char *argv[])
#endif
/*
- * for security, no dir or file created can be group or other
- * accessible
+ * for security, no dir or file created can be group or other accessible
*/
umask((mode_t) 0077);
@@ -419,10 +419,10 @@ PostmasterMain(int argc, char *argv[])
MemoryContextInit();
/*
- * By default, palloc() requests in the postmaster will be allocated
- * in the PostmasterContext, which is space that can be recycled by
- * backends. Allocated data that needs to be available to backends
- * should be allocated in TopMemoryContext.
+ * By default, palloc() requests in the postmaster will be allocated in
+ * the PostmasterContext, which is space that can be recycled by backends.
+ * Allocated data that needs to be available to backends should be
+ * allocated in TopMemoryContext.
*/
PostmasterContext = AllocSetContextCreate(TopMemoryContext,
"Postmaster",
@@ -496,8 +496,7 @@ PostmasterMain(int argc, char *argv[])
/*
* ignore this flag. This may be passed in because the
- * program was run as 'postgres -M' instead of
- * 'postmaster'
+ * program was run as 'postgres -M' instead of 'postmaster'
*/
break;
case 'N':
@@ -511,8 +510,7 @@ PostmasterMain(int argc, char *argv[])
case 'o':
/*
- * Other options to pass to the backend on the command
- * line
+ * Other options to pass to the backend on the command line
*/
snprintf(ExtraOptions + strlen(ExtraOptions),
sizeof(ExtraOptions) - strlen(ExtraOptions),
@@ -524,20 +522,18 @@ PostmasterMain(int argc, char *argv[])
case 'S':
/*
- * Start in 'S'ilent mode (disassociate from controlling
- * tty). You may also think of this as 'S'ysV mode since
- * it's most badly needed on SysV-derived systems like
- * SVR4 and HP-UX.
+ * Start in 'S'ilent mode (disassociate from controlling tty).
+ * You may also think of this as 'S'ysV mode since it's most
+ * badly needed on SysV-derived systems like SVR4 and HP-UX.
*/
SetConfigOption("silent_mode", "true", PGC_POSTMASTER, PGC_S_ARGV);
break;
case 's':
/*
- * In the event that some backend dumps core, send
- * SIGSTOP, rather than SIGQUIT, to all its peers. This
- * lets the wily post_hacker collect core dumps from
- * everyone.
+ * In the event that some backend dumps core, send SIGSTOP,
+ * rather than SIGQUIT, to all its peers. This lets the wily
+ * post_hacker collect core dumps from everyone.
*/
SendStop = true;
break;
@@ -593,13 +589,13 @@ PostmasterMain(int argc, char *argv[])
if (find_other_exec(argv[0], "postgres", PG_VERSIONSTR,
postgres_exec_path) < 0)
ereport(FATAL,
- (errmsg("%s: could not locate matching postgres executable",
- progname)));
+ (errmsg("%s: could not locate matching postgres executable",
+ progname)));
#endif
/*
- * Locate the proper configuration files and data directory, and
- * read postgresql.conf for the first time.
+ * Locate the proper configuration files and data directory, and read
+ * postgresql.conf for the first time.
*/
if (!SelectConfigFiles(userDoption, progname))
ExitPostmaster(2);
@@ -616,9 +612,8 @@ PostmasterMain(int argc, char *argv[])
if (NBuffers < 2 * MaxBackends || NBuffers < 16)
{
/*
- * Do not accept -B so small that backends are likely to starve
- * for lack of buffers. The specific choices here are somewhat
- * arbitrary.
+ * Do not accept -B so small that backends are likely to starve for
+ * lack of buffers. The specific choices here are somewhat arbitrary.
*/
write_stderr("%s: the number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16\n", progname);
ExitPostmaster(1);
@@ -654,15 +649,15 @@ PostmasterMain(int argc, char *argv[])
char **p;
ereport(DEBUG3,
- (errmsg_internal("%s: PostmasterMain: initial environ dump:",
- progname)));
+ (errmsg_internal("%s: PostmasterMain: initial environ dump:",
+ progname)));
ereport(DEBUG3,
- (errmsg_internal("-----------------------------------------")));
+ (errmsg_internal("-----------------------------------------")));
for (p = environ; *p; ++p)
ereport(DEBUG3,
(errmsg_internal("\t%s", *p)));
ereport(DEBUG3,
- (errmsg_internal("-----------------------------------------")));
+ (errmsg_internal("-----------------------------------------")));
}
/*
@@ -683,8 +678,8 @@ PostmasterMain(int argc, char *argv[])
/*
* Fork away from controlling terminal, if -S specified.
*
- * Must do this before we grab any interlock files, else the interlocks
- * will show the wrong PID.
+ * Must do this before we grab any interlock files, else the interlocks will
+ * show the wrong PID.
*/
if (SilentMode)
pmdaemonize();
@@ -692,18 +687,17 @@ PostmasterMain(int argc, char *argv[])
/*
* Create lockfile for data directory.
*
- * We want to do this before we try to grab the input sockets, because
- * the data directory interlock is more reliable than the socket-file
- * interlock (thanks to whoever decided to put socket files in /tmp
- * :-(). For the same reason, it's best to grab the TCP socket(s)
- * before the Unix socket.
+ * We want to do this before we try to grab the input sockets, because the
+ * data directory interlock is more reliable than the socket-file
+ * interlock (thanks to whoever decided to put socket files in /tmp :-().
+ * For the same reason, it's best to grab the TCP socket(s) before the
+ * Unix socket.
*/
CreateDataDirLockFile(true);
/*
* Remove old temporary files. At this point there can be no other
- * Postgres processes running in this directory, so this should be
- * safe.
+ * Postgres processes running in this directory, so this should be safe.
*/
RemovePgTempFiles();
@@ -729,7 +723,7 @@ PostmasterMain(int argc, char *argv[])
/* syntax error in list */
ereport(FATAL,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("invalid list syntax for \"listen_addresses\"")));
+ errmsg("invalid list syntax for \"listen_addresses\"")));
}
foreach(l, elemlist)
@@ -750,8 +744,8 @@ PostmasterMain(int argc, char *argv[])
success++;
else
ereport(WARNING,
- (errmsg("could not create listen socket for \"%s\"",
- curhost)));
+ (errmsg("could not create listen socket for \"%s\"",
+ curhost)));
}
if (!success && list_length(elemlist))
@@ -771,7 +765,7 @@ PostmasterMain(int argc, char *argv[])
"",
htonl(PostPortNumber),
"",
- (DNSServiceRegistrationReply) reg_reply,
+ (DNSServiceRegistrationReply) reg_reply,
NULL);
}
#endif
@@ -799,9 +793,8 @@ PostmasterMain(int argc, char *argv[])
reset_shared(PostPortNumber);
/*
- * Estimate number of openable files. This must happen after setting
- * up semaphores, because on some platforms semaphores count as open
- * files.
+ * Estimate number of openable files. This must happen after setting up
+ * semaphores, because on some platforms semaphores count as open files.
*/
set_max_safe_fds();
@@ -836,14 +829,13 @@ PostmasterMain(int argc, char *argv[])
TRUE,
DUPLICATE_SAME_ACCESS) == 0)
ereport(FATAL,
- (errmsg_internal("could not duplicate postmaster handle: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not duplicate postmaster handle: error code %d",
+ (int) GetLastError())));
#endif
/*
- * Record postmaster options. We delay this till now to avoid
- * recording bogus options (eg, NBuffers too high for available
- * memory).
+ * Record postmaster options. We delay this till now to avoid recording
+ * bogus options (eg, NBuffers too high for available memory).
*/
if (!CreateOptsFile(argc, argv, my_exec_path))
ExitPostmaster(1);
@@ -904,8 +896,8 @@ PostmasterMain(int argc, char *argv[])
SysLoggerPID = SysLogger_Start();
/*
- * Reset whereToSendOutput from Debug (its starting state) to None.
- * This stops ereport from sending log messages to stderr unless
+ * Reset whereToSendOutput from Debug (its starting state) to None. This
+ * stops ereport from sending log messages to stderr unless
* Log_destination permits. We don't do this until the postmaster is
* fully launched, since startup failures may as well be reported to
* stderr.
@@ -941,8 +933,7 @@ PostmasterMain(int argc, char *argv[])
status = ServerLoop();
/*
- * ServerLoop probably shouldn't ever return, but if it does, close
- * down.
+ * ServerLoop probably shouldn't ever return, but if it does, close down.
*/
ExitPostmaster(status != STATUS_OK);
@@ -972,8 +963,8 @@ checkDataDir(void)
else
ereport(FATAL,
(errcode_for_file_access(),
- errmsg("could not read permissions of directory \"%s\": %m",
- DataDir)));
+ errmsg("could not read permissions of directory \"%s\": %m",
+ DataDir)));
}
/*
@@ -997,13 +988,13 @@ checkDataDir(void)
/*
* Check if the directory has group or world access. If so, reject.
*
- * It would be possible to allow weaker constraints (for example, allow
- * group access) but we cannot make a general assumption that that is
- * okay; for example there are platforms where nearly all users customarily
- * belong to the same group. Perhaps this test should be configurable.
+ * It would be possible to allow weaker constraints (for example, allow group
+ * access) but we cannot make a general assumption that that is okay; for
+ * example there are platforms where nearly all users customarily belong
+ * to the same group. Perhaps this test should be configurable.
*
- * XXX temporarily suppress check when on Windows, because there may not
- * be proper support for Unix-y file permissions. Need to think of a
+ * XXX temporarily suppress check when on Windows, because there may not be
+ * proper support for Unix-y file permissions. Need to think of a
* reasonable check to apply on Windows.
*/
#if !defined(WIN32) && !defined(__CYGWIN__)
@@ -1129,9 +1120,9 @@ usage(const char *progname)
printf(_(" -s send SIGSTOP to all backend servers if one dies\n"));
printf(_("\nPlease read the documentation for the complete list of run-time\n"
- "configuration settings and how to set them on the command line or in\n"
- "the configuration file.\n\n"
- "Report bugs to <pgsql-bugs@postgresql.org>.\n"));
+ "configuration settings and how to set them on the command line or in\n"
+ "the configuration file.\n\n"
+ "Report bugs to <pgsql-bugs@postgresql.org>.\n"));
}
@@ -1165,9 +1156,9 @@ ServerLoop(void)
/*
* Wait for something to happen.
*
- * We wait at most one minute, or the minimum autovacuum delay, to
- * ensure that the other background tasks handled below get done
- * even when no requests are arriving.
+ * We wait at most one minute, or the minimum autovacuum delay, to ensure
+ * that the other background tasks handled below get done even when no
+ * requests are arriving.
*/
memcpy((char *) &rmask, (char *) &readmask, sizeof(fd_set));
@@ -1179,8 +1170,8 @@ ServerLoop(void)
selres = select(nSockets, &rmask, NULL, NULL, &timeout);
/*
- * Block all signals until we wait again. (This makes it safe for
- * our signal handlers to do nontrivial work.)
+ * Block all signals until we wait again. (This makes it safe for our
+ * signal handlers to do nontrivial work.)
*/
PG_SETMASK(&BlockSig);
@@ -1196,14 +1187,13 @@ ServerLoop(void)
}
/*
- * New connection pending on any of our sockets? If so, fork a
- * child process to deal with it.
+ * New connection pending on any of our sockets? If so, fork a child
+ * process to deal with it.
*/
if (selres > 0)
{
/*
- * Select a random seed at the time of first receiving a
- * request.
+ * Select a random seed at the time of first receiving a request.
*/
while (random_seed == 0)
{
@@ -1212,8 +1202,8 @@ ServerLoop(void)
/*
* We are not sure how much precision is in tv_usec, so we
* swap the high and low 16 bits of 'later' and XOR them with
- * 'earlier'. On the off chance that the result is 0, we
- * loop until it isn't.
+ * 'earlier'. On the off chance that the result is 0, we loop
+ * until it isn't.
*/
random_seed = earlier.tv_usec ^
((later.tv_usec << 16) |
@@ -1232,8 +1222,8 @@ ServerLoop(void)
BackendStartup(port);
/*
- * We no longer need the open socket or port
- * structure in this process
+ * We no longer need the open socket or port structure
+ * in this process
*/
StreamClose(port->sock);
ConnFree(port);
@@ -1261,8 +1251,8 @@ ServerLoop(void)
/*
* Start a new autovacuum process, if there isn't one running already.
- * (It'll die relatively quickly.) We check that it's not started
- * too frequently in autovac_start.
+ * (It'll die relatively quickly.) We check that it's not started too
+ * frequently in autovac_start.
*/
if (AutoVacuumingActive() && AutoVacPID == 0 &&
StartupPID == 0 && !FatalError && Shutdown == NoShutdown)
@@ -1279,10 +1269,9 @@ ServerLoop(void)
PgStatPID = pgstat_start();
/*
- * Touch the socket and lock file every 58 minutes, to
- * ensure that they are not removed by overzealous /tmp-cleaning
- * tasks. We assume no one runs cleaners with cutoff times of
- * less than an hour ...
+ * Touch the socket and lock file every 58 minutes, to ensure that
+ * they are not removed by overzealous /tmp-cleaning tasks. We assume
+ * no one runs cleaners with cutoff times of less than an hour ...
*/
now = time(NULL);
if (now - last_touch_time >= 58 * SECS_PER_MINUTE)
@@ -1345,8 +1334,8 @@ ProcessStartupPacket(Port *port, bool SSLdone)
{
/*
* EOF after SSLdone probably means the client didn't like our
- * response to NEGOTIATE_SSL_CODE. That's not an error condition,
- * so don't clutter the log with a complaint.
+ * response to NEGOTIATE_SSL_CODE. That's not an error condition, so
+ * don't clutter the log with a complaint.
*/
if (!SSLdone)
ereport(COMMERROR,
@@ -1369,9 +1358,9 @@ ProcessStartupPacket(Port *port, bool SSLdone)
/*
* Allocate at least the size of an old-style startup packet, plus one
- * extra byte, and make sure all are zeroes. This ensures we will
- * have null termination of all strings, in both fixed- and
- * variable-length packet layouts.
+ * extra byte, and make sure all are zeroes. This ensures we will have
+ * null termination of all strings, in both fixed- and variable-length
+ * packet layouts.
*/
if (len <= (int32) sizeof(StartupPacket))
buf = palloc0(sizeof(StartupPacket) + 1);
@@ -1415,7 +1404,7 @@ ProcessStartupPacket(Port *port, bool SSLdone)
{
ereport(COMMERROR,
(errcode_for_socket_access(),
- errmsg("failed to send SSL negotiation response: %m")));
+ errmsg("failed to send SSL negotiation response: %m")));
return STATUS_ERROR; /* close the connection */
}
@@ -1431,32 +1420,32 @@ ProcessStartupPacket(Port *port, bool SSLdone)
/* Could add additional special packet types here */
/*
- * Set FrontendProtocol now so that ereport() knows what format to
- * send if we fail during startup.
+ * Set FrontendProtocol now so that ereport() knows what format to send if
+ * we fail during startup.
*/
FrontendProtocol = proto;
/* Check we can handle the protocol the frontend is using. */
if (PG_PROTOCOL_MAJOR(proto) < PG_PROTOCOL_MAJOR(PG_PROTOCOL_EARLIEST) ||
- PG_PROTOCOL_MAJOR(proto) > PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) ||
- (PG_PROTOCOL_MAJOR(proto) == PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) &&
- PG_PROTOCOL_MINOR(proto) > PG_PROTOCOL_MINOR(PG_PROTOCOL_LATEST)))
+ PG_PROTOCOL_MAJOR(proto) > PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) ||
+ (PG_PROTOCOL_MAJOR(proto) == PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) &&
+ PG_PROTOCOL_MINOR(proto) > PG_PROTOCOL_MINOR(PG_PROTOCOL_LATEST)))
ereport(FATAL,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("unsupported frontend protocol %u.%u: server supports %u.0 to %u.%u",
- PG_PROTOCOL_MAJOR(proto), PG_PROTOCOL_MINOR(proto),
+ PG_PROTOCOL_MAJOR(proto), PG_PROTOCOL_MINOR(proto),
PG_PROTOCOL_MAJOR(PG_PROTOCOL_EARLIEST),
PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST),
PG_PROTOCOL_MINOR(PG_PROTOCOL_LATEST))));
/*
- * Now fetch parameters out of startup packet and save them into the
- * Port structure. All data structures attached to the Port struct
- * must be allocated in TopMemoryContext so that they won't disappear
- * when we pass them to PostgresMain (see BackendRun). We need not
- * worry about leaking this storage on failure, since we aren't in the
- * postmaster process anymore.
+ * Now fetch parameters out of startup packet and save them into the Port
+ * structure. All data structures attached to the Port struct must be
+ * allocated in TopMemoryContext so that they won't disappear when we pass
+ * them to PostgresMain (see BackendRun). We need not worry about leaking
+ * this storage on failure, since we aren't in the postmaster process
+ * anymore.
*/
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
@@ -1465,9 +1454,9 @@ ProcessStartupPacket(Port *port, bool SSLdone)
int32 offset = sizeof(ProtocolVersion);
/*
- * Scan packet body for name/option pairs. We can assume any
- * string beginning within the packet body is null-terminated,
- * thanks to zeroing extra byte above.
+ * Scan packet body for name/option pairs. We can assume any string
+ * beginning within the packet body is null-terminated, thanks to
+ * zeroing extra byte above.
*/
port->guc_options = NIL;
@@ -1513,11 +1502,10 @@ ProcessStartupPacket(Port *port, bool SSLdone)
else
{
/*
- * Get the parameters from the old-style, fixed-width-fields
- * startup packet as C strings. The packet destination was
- * cleared first so a short packet has zeros silently added. We
- * have to be prepared to truncate the pstrdup result for oversize
- * fields, though.
+ * Get the parameters from the old-style, fixed-width-fields startup
+ * packet as C strings. The packet destination was cleared first so a
+ * short packet has zeros silently added. We have to be prepared to
+ * truncate the pstrdup result for oversize fields, though.
*/
StartupPacket *packet = (StartupPacket *) buf;
@@ -1537,7 +1525,7 @@ ProcessStartupPacket(Port *port, bool SSLdone)
if (port->user_name == NULL || port->user_name[0] == '\0')
ereport(FATAL,
(errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
- errmsg("no PostgreSQL user name specified in startup packet")));
+ errmsg("no PostgreSQL user name specified in startup packet")));
/* The database defaults to the user name. */
if (port->database_name == NULL || port->database_name[0] == '\0')
@@ -1546,10 +1534,10 @@ ProcessStartupPacket(Port *port, bool SSLdone)
if (Db_user_namespace)
{
/*
- * If user@, it is a global user, remove '@'. We only want to do
- * this if there is an '@' at the end and no earlier in the user
- * string or they may fake as a local user of another database
- * attaching to this database.
+ * If user@, it is a global user, remove '@'. We only want to do this
+ * if there is an '@' at the end and no earlier in the user string or
+ * they may fake as a local user of another database attaching to this
+ * database.
*/
if (strchr(port->user_name, '@') ==
port->user_name + strlen(port->user_name) - 1)
@@ -1567,8 +1555,8 @@ ProcessStartupPacket(Port *port, bool SSLdone)
}
/*
- * Truncate given database and user names to length of a Postgres
- * name. This avoids lookup failures when overlength names are given.
+ * Truncate given database and user names to length of a Postgres name.
+ * This avoids lookup failures when overlength names are given.
*/
if (strlen(port->database_name) >= NAMEDATALEN)
port->database_name[NAMEDATALEN - 1] = '\0';
@@ -1581,9 +1569,9 @@ ProcessStartupPacket(Port *port, bool SSLdone)
MemoryContextSwitchTo(oldcontext);
/*
- * If we're going to reject the connection due to database state, say
- * so now instead of wasting cycles on an authentication exchange.
- * (This also allows a pg_ping utility to be written.)
+ * If we're going to reject the connection due to database state, say so
+ * now instead of wasting cycles on an authentication exchange. (This also
+ * allows a pg_ping utility to be written.)
*/
switch (port->canAcceptConnections)
{
@@ -1628,6 +1616,7 @@ processCancelRequest(Port *port, void *pkt)
int backendPID;
long cancelAuthCode;
Backend *bp;
+
#ifndef EXEC_BACKEND
Dlelem *curr;
#else
@@ -1638,9 +1627,9 @@ processCancelRequest(Port *port, void *pkt)
cancelAuthCode = (long) ntohl(canc->cancelAuthCode);
/*
- * See if we have a matching backend. In the EXEC_BACKEND case, we
- * can no longer access the postmaster's own backend list, and must
- * rely on the duplicate array in shared memory.
+ * See if we have a matching backend. In the EXEC_BACKEND case, we can no
+ * longer access the postmaster's own backend list, and must rely on the
+ * duplicate array in shared memory.
*/
#ifndef EXEC_BACKEND
for (curr = DLGetHead(BackendList); curr; curr = DLGetSucc(curr))
@@ -1664,8 +1653,8 @@ processCancelRequest(Port *port, void *pkt)
else
/* Right PID, wrong key: no way, Jose */
ereport(DEBUG2,
- (errmsg_internal("bad key in cancel request for process %d",
- backendPID)));
+ (errmsg_internal("bad key in cancel request for process %d",
+ backendPID)));
return;
}
}
@@ -1694,10 +1683,10 @@ canAcceptConnections(void)
* Don't start too many children.
*
* We allow more connections than we can have backends here because some
- * might still be authenticating; they might fail auth, or some
- * existing backend might exit before the auth cycle is completed. The
- * exact MaxBackends limit is enforced when a new backend tries to
- * join the shared-inval backend array.
+ * might still be authenticating; they might fail auth, or some existing
+ * backend might exit before the auth cycle is completed. The exact
+ * MaxBackends limit is enforced when a new backend tries to join the
+ * shared-inval backend array.
*/
if (CountChildren() >= 2 * MaxBackends)
return CAC_TOOMANY;
@@ -1731,12 +1720,11 @@ ConnCreate(int serverFd)
else
{
/*
- * Precompute password salt values to use for this connection.
- * It's slightly annoying to do this long in advance of knowing
- * whether we'll need 'em or not, but we must do the random()
- * calls before we fork, not after. Else the postmaster's random
- * sequence won't get advanced, and all backends would end up
- * using the same salt...
+ * Precompute password salt values to use for this connection. It's
+ * slightly annoying to do this long in advance of knowing whether
+ * we'll need 'em or not, but we must do the random() calls before we
+ * fork, not after. Else the postmaster's random sequence won't get
+ * advanced, and all backends would end up using the same salt...
*/
RandomSalt(port->cryptSalt, port->md5Salt);
}
@@ -1808,10 +1796,10 @@ reset_shared(int port)
/*
* Create or re-create shared memory and semaphores.
*
- * Note: in each "cycle of life" we will normally assign the same IPC
- * keys (if using SysV shmem and/or semas), since the port number is
- * used to determine IPC keys. This helps ensure that we will clean
- * up dead IPC objects if the postmaster crashes and is restarted.
+ * Note: in each "cycle of life" we will normally assign the same IPC keys
+ * (if using SysV shmem and/or semas), since the port number is used to
+ * determine IPC keys. This helps ensure that we will clean up dead IPC
+ * objects if the postmaster crashes and is restarted.
*/
CreateSharedMemoryAndSemaphores(false, port);
}
@@ -1830,7 +1818,7 @@ SIGHUP_handler(SIGNAL_ARGS)
if (Shutdown <= SmartShutdown)
{
ereport(LOG,
- (errmsg("received SIGHUP, reloading configuration files")));
+ (errmsg("received SIGHUP, reloading configuration files")));
ProcessConfigFile(PGC_SIGHUP);
SignalChildren(SIGHUP);
if (BgWriterPID != 0)
@@ -1925,8 +1913,8 @@ pmdie(SIGNAL_ARGS)
/*
* Fast Shutdown:
*
- * Abort all children with SIGTERM (rollback active transactions
- * and exit) and shut down when they are gone.
+ * Abort all children with SIGTERM (rollback active transactions and
+ * exit) and shut down when they are gone.
*/
if (Shutdown >= FastShutdown)
break;
@@ -1951,8 +1939,8 @@ pmdie(SIGNAL_ARGS)
/*
* No children left. Begin shutdown of data base system.
*
- * Note: if we previously got SIGTERM then we may send SIGUSR2 to
- * the bgwriter a second time here. This should be harmless.
+ * Note: if we previously got SIGTERM then we may send SIGUSR2 to the
+ * bgwriter a second time here. This should be harmless.
*/
if (StartupPID != 0 || FatalError)
break; /* let reaper() handle this */
@@ -2011,7 +1999,6 @@ reaper(SIGNAL_ARGS)
#ifdef HAVE_WAITPID
int status; /* backend exit status */
-
#else
#ifndef WIN32
union wait status; /* backend exit status */
@@ -2037,10 +2024,9 @@ reaper(SIGNAL_ARGS)
while ((pid = win32_waitpid(&exitstatus)) > 0)
{
/*
- * We need to do this here, and not in CleanupBackend, since this
- * is to be called on all children when we are done with them.
- * Could move to LogChildExit, but that seems like asking for
- * future trouble...
+ * We need to do this here, and not in CleanupBackend, since this is
+ * to be called on all children when we are done with them. Could move
+ * to LogChildExit, but that seems like asking for future trouble...
*/
win32_RemoveChild(pid);
#endif /* WIN32 */
@@ -2057,7 +2043,7 @@ reaper(SIGNAL_ARGS)
LogChildExit(LOG, _("startup process"),
pid, exitstatus);
ereport(LOG,
- (errmsg("aborting startup due to startup process failure")));
+ (errmsg("aborting startup due to startup process failure")));
ExitPostmaster(1);
}
@@ -2068,9 +2054,9 @@ reaper(SIGNAL_ARGS)
FatalError = false;
/*
- * Load the flat authorization file into postmaster's cache.
- * The startup process has recomputed this from the database
- * contents, so we wait till it finishes before loading it.
+ * Load the flat authorization file into postmaster's cache. The
+ * startup process has recomputed this from the database contents,
+ * so we wait till it finishes before loading it.
*/
load_role();
@@ -2083,8 +2069,8 @@ reaper(SIGNAL_ARGS)
/*
* Go to shutdown mode if a shutdown request was pending.
- * Otherwise, try to start the archiver and stats collector
- * too. (We could, but don't, try to start autovacuum here.)
+ * Otherwise, try to start the archiver and stats collector too.
+ * (We could, but don't, try to start autovacuum here.)
*/
if (Shutdown > NoShutdown && BgWriterPID != 0)
kill(BgWriterPID, SIGUSR2);
@@ -2109,16 +2095,15 @@ reaper(SIGNAL_ARGS)
!DLGetHead(BackendList) && AutoVacPID == 0)
{
/*
- * Normal postmaster exit is here: we've seen normal exit
- * of the bgwriter after it's been told to shut down. We
- * expect that it wrote a shutdown checkpoint. (If for
- * some reason it didn't, recovery will occur on next
- * postmaster start.)
+ * Normal postmaster exit is here: we've seen normal exit of
+ * the bgwriter after it's been told to shut down. We expect
+ * that it wrote a shutdown checkpoint. (If for some reason
+ * it didn't, recovery will occur on next postmaster start.)
*
- * Note: we do not wait around for exit of the archiver or
- * stats processes. They've been sent SIGQUIT by this
- * point, and in any case contain logic to commit
- * hara-kiri if they notice the postmaster is gone.
+ * Note: we do not wait around for exit of the archiver or stats
+ * processes. They've been sent SIGQUIT by this point, and in
+ * any case contain logic to commit hara-kiri if they notice
+ * the postmaster is gone.
*/
ExitPostmaster(0);
}
@@ -2132,9 +2117,9 @@ reaper(SIGNAL_ARGS)
}
/*
- * Was it the autovacuum process? Normal exit can be ignored;
- * we'll start a new one at the next iteration of the postmaster's
- * main loop, if necessary.
+ * Was it the autovacuum process? Normal exit can be ignored; we'll
+ * start a new one at the next iteration of the postmaster's main
+ * loop, if necessary.
*
* An unexpected exit must crash the system.
*/
@@ -2149,9 +2134,9 @@ reaper(SIGNAL_ARGS)
}
/*
- * Was it the archiver? If so, just try to start a new one; no
- * need to force reset of the rest of the system. (If fail, we'll
- * try again in future cycles of the main loop.)
+ * Was it the archiver? If so, just try to start a new one; no need
+ * to force reset of the rest of the system. (If fail, we'll try
+ * again in future cycles of the main loop.)
*/
if (PgArchPID != 0 && pid == PgArchPID)
{
@@ -2166,9 +2151,9 @@ reaper(SIGNAL_ARGS)
}
/*
- * Was it the statistics collector? If so, just try to start a
- * new one; no need to force reset of the rest of the system. (If
- * fail, we'll try again in future cycles of the main loop.)
+ * Was it the statistics collector? If so, just try to start a new
+ * one; no need to force reset of the rest of the system. (If fail,
+ * we'll try again in future cycles of the main loop.)
*/
if (PgStatPID != 0 && pid == PgStatPID)
{
@@ -2203,14 +2188,14 @@ reaper(SIGNAL_ARGS)
{
/*
* Wait for all important children to exit, then reset shmem and
- * StartupDataBase. (We can ignore the archiver and stats
- * processes here since they are not connected to shmem.)
+ * StartupDataBase. (We can ignore the archiver and stats processes
+ * here since they are not connected to shmem.)
*/
if (DLGetHead(BackendList) || StartupPID != 0 || BgWriterPID != 0 ||
AutoVacPID != 0)
goto reaper_done;
ereport(LOG,
- (errmsg("all server processes terminated; reinitializing")));
+ (errmsg("all server processes terminated; reinitializing")));
shmem_exit(0);
reset_shared(PostPortNumber);
@@ -2259,10 +2244,10 @@ CleanupBackend(int pid,
LogChildExit(DEBUG2, _("server process"), pid, exitstatus);
/*
- * If a backend dies in an ugly way (i.e. exit status not 0) then we
- * must signal all other backends to quickdie. If exit status is zero
- * we assume everything is hunky dory and simply remove the backend
- * from the active backend list.
+ * If a backend dies in an ugly way (i.e. exit status not 0) then we must
+ * signal all other backends to quickdie. If exit status is zero we
+ * assume everything is hunky dory and simply remove the backend from the
+ * active backend list.
*/
if (exitstatus != 0)
{
@@ -2303,15 +2288,14 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
Backend *bp;
/*
- * Make log entry unless there was a previous crash (if so, nonzero
- * exit status is to be expected in SIGQUIT response; don't clutter
- * log)
+ * Make log entry unless there was a previous crash (if so, nonzero exit
+ * status is to be expected in SIGQUIT response; don't clutter log)
*/
if (!FatalError)
{
LogChildExit(LOG, procname, pid, exitstatus);
ereport(LOG,
- (errmsg("terminating any other active server processes")));
+ (errmsg("terminating any other active server processes")));
}
/* Process regular backends */
@@ -2337,19 +2321,19 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
else
{
/*
- * This backend is still alive. Unless we did so already,
- * tell it to commit hara-kiri.
+ * This backend is still alive. Unless we did so already, tell it
+ * to commit hara-kiri.
*
- * SIGQUIT is the special signal that says exit without proc_exit
- * and let the user know what's going on. But if SendStop is
- * set (-s on command line), then we send SIGSTOP instead, so
- * that we can get core dumps from all backends by hand.
+ * SIGQUIT is the special signal that says exit without proc_exit and
+ * let the user know what's going on. But if SendStop is set (-s
+ * on command line), then we send SIGSTOP instead, so that we can
+ * get core dumps from all backends by hand.
*/
if (!FatalError)
{
ereport(DEBUG2,
(errmsg_internal("sending %s to process %d",
- (SendStop ? "SIGSTOP" : "SIGQUIT"),
+ (SendStop ? "SIGSTOP" : "SIGQUIT"),
(int) bp->pid)));
kill(bp->pid, (SendStop ? SIGSTOP : SIGQUIT));
}
@@ -2417,8 +2401,8 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus)
ereport(lev,
/*
- * translator: %s is a noun phrase describing a child process,
- * such as "server process"
+ * translator: %s is a noun phrase describing a child process, such as
+ * "server process"
*/
(errmsg("%s (PID %d) exited with exit code %d",
procname, pid, WEXITSTATUS(exitstatus))));
@@ -2426,8 +2410,8 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus)
ereport(lev,
/*
- * translator: %s is a noun phrase describing a child process,
- * such as "server process"
+ * translator: %s is a noun phrase describing a child process, such as
+ * "server process"
*/
(errmsg("%s (PID %d) was terminated by signal %d",
procname, pid, WTERMSIG(exitstatus))));
@@ -2435,8 +2419,8 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus)
ereport(lev,
/*
- * translator: %s is a noun phrase describing a child process,
- * such as "server process"
+ * translator: %s is a noun phrase describing a child process, such as
+ * "server process"
*/
(errmsg("%s (PID %d) exited with unexpected status %d",
procname, pid, exitstatus)));
@@ -2480,8 +2464,8 @@ BackendStartup(Port *port)
MyCancelKey = PostmasterRandom();
/*
- * Make room for backend data structure. Better before the fork() so
- * we can handle failure cleanly.
+ * Make room for backend data structure. Better before the fork() so we
+ * can handle failure cleanly.
*/
bn = (Backend *) malloc(sizeof(Backend));
if (!bn)
@@ -2514,7 +2498,7 @@ BackendStartup(Port *port)
free(bn);
errno = save_errno;
ereport(LOG,
- (errmsg("could not fork new process for connection: %m")));
+ (errmsg("could not fork new process for connection: %m")));
report_fork_failure_to_client(port, save_errno);
return STATUS_ERROR;
}
@@ -2525,8 +2509,8 @@ BackendStartup(Port *port)
(int) pid, port->sock)));
/*
- * Everything's been successful, it's safe to add this backend to our
- * list of backends.
+ * Everything's been successful, it's safe to add this backend to our list
+ * of backends.
*/
bn->pid = pid;
bn->cancel_key = MyCancelKey;
@@ -2638,10 +2622,10 @@ BackendRun(Port *port)
/*
* PreAuthDelay is a debugging aid for investigating problems in the
- * authentication cycle: it can be set in postgresql.conf to allow
- * time to attach to the newly-forked backend with a debugger. (See
- * also the -W backend switch, which we allow clients to pass through
- * PGOPTIONS, but it is not honored until after authentication.)
+ * authentication cycle: it can be set in postgresql.conf to allow time to
+ * attach to the newly-forked backend with a debugger. (See also the -W
+ * backend switch, which we allow clients to pass through PGOPTIONS, but
+ * it is not honored until after authentication.)
*/
if (PreAuthDelay > 0)
pg_usleep(PreAuthDelay * 1000000L);
@@ -2657,18 +2641,17 @@ BackendRun(Port *port)
port->commandTag = "";
/*
- * Initialize libpq and enable reporting of ereport errors to the
- * client. Must do this now because authentication uses libpq to send
- * messages.
+ * Initialize libpq and enable reporting of ereport errors to the client.
+ * Must do this now because authentication uses libpq to send messages.
*/
pq_init(); /* initialize libpq to talk to client */
whereToSendOutput = Remote; /* now safe to ereport to client */
/*
- * We arrange for a simple exit(0) if we receive SIGTERM or SIGQUIT
- * during any client authentication related communication. Otherwise
- * the postmaster cannot shutdown the database FAST or IMMED cleanly
- * if a buggy client blocks a backend during authentication.
+ * We arrange for a simple exit(0) if we receive SIGTERM or SIGQUIT during
+ * any client authentication related communication. Otherwise the
+ * postmaster cannot shutdown the database FAST or IMMED cleanly if a
+ * buggy client blocks a backend during authentication.
*/
pqsignal(SIGTERM, authdie);
pqsignal(SIGQUIT, authdie);
@@ -2683,12 +2666,12 @@ BackendRun(Port *port)
if (getnameinfo_all(&port->raddr.addr, port->raddr.salen,
remote_host, sizeof(remote_host),
remote_port, sizeof(remote_port),
- (log_hostname ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV))
+ (log_hostname ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV))
{
int ret = getnameinfo_all(&port->raddr.addr, port->raddr.salen,
- remote_host, sizeof(remote_host),
- remote_port, sizeof(remote_port),
- NI_NUMERICHOST | NI_NUMERICSERV);
+ remote_host, sizeof(remote_host),
+ remote_port, sizeof(remote_port),
+ NI_NUMERICHOST | NI_NUMERICSERV);
if (ret)
ereport(WARNING,
@@ -2713,9 +2696,9 @@ BackendRun(Port *port)
/*
* In EXEC_BACKEND case, we didn't inherit the contents of pg_hba.conf
- * etcetera from the postmaster, and have to load them ourselves.
- * Build the PostmasterContext (which didn't exist before, in this
- * process) to contain the data.
+ * etcetera from the postmaster, and have to load them ourselves. Build
+ * the PostmasterContext (which didn't exist before, in this process) to
+ * contain the data.
*
* FIXME: [fork/exec] Ugh. Is there a way around this overhead?
*/
@@ -2734,16 +2717,16 @@ BackendRun(Port *port)
#endif
/*
- * Ready to begin client interaction. We will give up and exit(0)
- * after a time delay, so that a broken client can't hog a connection
+ * Ready to begin client interaction. We will give up and exit(0) after a
+ * time delay, so that a broken client can't hog a connection
* indefinitely. PreAuthDelay doesn't count against the time limit.
*/
if (!enable_sig_alarm(AuthenticationTimeout * 1000, false))
elog(FATAL, "could not set timer for authorization timeout");
/*
- * Receive the startup packet (which might turn out to be a cancel
- * request packet).
+ * Receive the startup packet (which might turn out to be a cancel request
+ * packet).
*/
status = ProcessStartupPacket(port, false);
@@ -2752,8 +2735,7 @@ BackendRun(Port *port)
/*
* Now that we have the user and database name, we can set the process
- * title for ps. It's good to do this as early as possible in
- * startup.
+ * title for ps. It's good to do this as early as possible in startup.
*/
init_ps_display(port->user_name, port->database_name, remote_ps_data);
set_ps_display("authentication");
@@ -2764,8 +2746,8 @@ BackendRun(Port *port)
ClientAuthentication(port); /* might not return, if failure */
/*
- * Done with authentication. Disable timeout, and prevent
- * SIGTERM/SIGQUIT again until backend startup is complete.
+ * Done with authentication. Disable timeout, and prevent SIGTERM/SIGQUIT
+ * again until backend startup is complete.
*/
if (!disable_sig_alarm(false))
elog(FATAL, "could not disable timer for authorization timeout");
@@ -2778,8 +2760,8 @@ BackendRun(Port *port)
/*
* Don't want backend to be able to see the postmaster random number
- * generator state. We have to clobber the static random_seed *and*
- * start a new random sequence in the random() library function.
+ * generator state. We have to clobber the static random_seed *and* start
+ * a new random sequence in the random() library function.
*/
random_seed = 0;
srandom((unsigned int) (MyProcPid ^ port->session_start.tv_usec));
@@ -2826,8 +2808,8 @@ BackendRun(Port *port)
av[ac++] = port->database_name;
/*
- * Pass the (insecure) option switches from the connection request.
- * (It's OK to mangle port->cmdline_options now.)
+ * Pass the (insecure) option switches from the connection request. (It's
+ * OK to mangle port->cmdline_options now.)
*/
if (port->cmdline_options)
split_opts(av, &ac, port->cmdline_options);
@@ -2837,11 +2819,11 @@ BackendRun(Port *port)
Assert(ac < maxac);
/*
- * Release postmaster's working memory context so that backend can
- * recycle the space. Note this does not trash *MyProcPort, because
- * ConnCreate() allocated that space with malloc() ... else we'd need
- * to copy the Port data here. Also, subsidiary data such as the
- * username isn't lost either; see ProcessStartupPacket().
+ * Release postmaster's working memory context so that backend can recycle
+ * the space. Note this does not trash *MyProcPort, because ConnCreate()
+ * allocated that space with malloc() ... else we'd need to copy the Port
+ * data here. Also, subsidiary data such as the username isn't lost
+ * either; see ProcessStartupPacket().
*/
MemoryContextSwitchTo(TopMemoryContext);
MemoryContextDelete(PostmasterContext);
@@ -2852,15 +2834,14 @@ BackendRun(Port *port)
*/
ereport(DEBUG3,
(errmsg_internal("%s child[%d]: starting with (",
- progname, (int)getpid())));
+ progname, (int) getpid())));
for (i = 0; i < ac; ++i)
ereport(DEBUG3,
(errmsg_internal("\t%s", av[i])));
ereport(DEBUG3,
(errmsg_internal(")")));
- ClientAuthInProgress = false; /* client_min_messages is active
- * now */
+ ClientAuthInProgress = false; /* client_min_messages is active now */
return (PostgresMain(ac, av, port->user_name));
}
@@ -2926,7 +2907,7 @@ internal_forkexec(int argc, char *argv[], Port *port)
pid_t pid;
char tmpfilename[MAXPGPATH];
BackendParameters param;
- FILE *fp;
+ FILE *fp;
if (!save_backend_variables(&param, port))
return -1; /* log made by save_backend_variables */
@@ -2994,21 +2975,19 @@ internal_forkexec(int argc, char *argv[], Port *port)
}
}
- return pid; /* Parent returns pid, or -1 on fork
- * failure */
+ return pid; /* Parent returns pid, or -1 on fork failure */
}
-
-#else /* WIN32 */
+#else /* WIN32 */
/*
* internal_forkexec win32 implementation
*
* - starts backend using CreateProcess(), in suspended state
* - writes out backend variables to the parameter file
- * - during this, duplicates handles and sockets required for
- * inheritance into the new process
+ * - during this, duplicates handles and sockets required for
+ * inheritance into the new process
* - resumes execution of the new process once the backend parameter
- * file is complete.
+ * file is complete.
*/
static pid_t
internal_forkexec(int argc, char *argv[], Port *port)
@@ -3020,10 +2999,10 @@ internal_forkexec(int argc, char *argv[], Port *port)
char cmdLine[MAXPGPATH * 2];
HANDLE childHandleCopy;
HANDLE waiterThread;
- HANDLE paramHandle;
+ HANDLE paramHandle;
BackendParameters *param;
SECURITY_ATTRIBUTES sa;
- char paramHandleStr[32];
+ char paramHandleStr[32];
/* Make sure caller set up argv properly */
Assert(argc >= 3);
@@ -3032,7 +3011,7 @@ internal_forkexec(int argc, char *argv[], Port *port)
Assert(argv[2] == NULL);
/* Set up shared memory for parameter passing */
- ZeroMemory(&sa,sizeof(sa));
+ ZeroMemory(&sa, sizeof(sa));
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
paramHandle = CreateFileMapping(INVALID_HANDLE_VALUE,
@@ -3058,7 +3037,7 @@ internal_forkexec(int argc, char *argv[], Port *port)
}
/* Insert temp file name after -fork argument */
- sprintf(paramHandleStr, "%lu", (DWORD)paramHandle);
+ sprintf(paramHandleStr, "%lu", (DWORD) paramHandle);
argv[2] = paramHandleStr;
/* Format the cmd line */
@@ -3080,9 +3059,10 @@ internal_forkexec(int argc, char *argv[], Port *port)
memset(&pi, 0, sizeof(pi));
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
+
/*
- * Create the subprocess in a suspended state. This will be resumed
- * later, once we have written out the parameter file.
+ * Create the subprocess in a suspended state. This will be resumed later,
+ * once we have written out the parameter file.
*/
if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED,
NULL, NULL, &si, &pi))
@@ -3095,8 +3075,8 @@ internal_forkexec(int argc, char *argv[], Port *port)
if (!save_backend_variables(param, port, pi.hProcess, pi.dwProcessId))
{
/*
- * log made by save_backend_variables, but we have to clean
- * up the mess with the half-started process
+ * log made by save_backend_variables, but we have to clean up the
+ * mess with the half-started process
*/
if (!TerminateProcess(pi.hProcess, 255))
ereport(ERROR,
@@ -3116,9 +3096,9 @@ internal_forkexec(int argc, char *argv[], Port *port)
(int) GetLastError());
/*
- * Now that the backend variables are written out, we start the
- * child thread so it can start initializing while we set up
- * the rest of the parent state.
+ * Now that the backend variables are written out, we start the child
+ * thread so it can start initializing while we set up the rest of the
+ * parent state.
*/
if (ResumeThread(pi.hThread) == -1)
{
@@ -3154,15 +3134,15 @@ internal_forkexec(int argc, char *argv[], Port *port)
FALSE,
DUPLICATE_SAME_ACCESS) == 0)
ereport(FATAL,
- (errmsg_internal("could not duplicate child handle: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not duplicate child handle: error code %d",
+ (int) GetLastError())));
waiterThread = CreateThread(NULL, 64 * 1024, win32_sigchld_waiter,
(LPVOID) childHandleCopy, 0, NULL);
if (!waiterThread)
ereport(FATAL,
- (errmsg_internal("could not create sigchld waiter thread: error code %d",
- (int) GetLastError())));
+ (errmsg_internal("could not create sigchld waiter thread: error code %d",
+ (int) GetLastError())));
CloseHandle(waiterThread);
if (IsUnderPostmaster)
@@ -3171,8 +3151,7 @@ internal_forkexec(int argc, char *argv[], Port *port)
return pi.dwProcessId;
}
-
-#endif /* WIN32 */
+#endif /* WIN32 */
/*
@@ -3213,9 +3192,9 @@ SubPostmasterMain(int argc, char *argv[])
elog(FATAL, "invalid subpostmaster invocation");
/*
- * If appropriate, physically re-attach to shared memory segment.
- * We want to do this before going any further to ensure that we
- * can attach at the same address the postmaster used.
+ * If appropriate, physically re-attach to shared memory segment. We want
+ * to do this before going any further to ensure that we can attach at the
+ * same address the postmaster used.
*/
if (strcmp(argv[1], "-forkbackend") == 0 ||
strcmp(argv[1], "-forkautovac") == 0 ||
@@ -3223,9 +3202,9 @@ SubPostmasterMain(int argc, char *argv[])
PGSharedMemoryReAttach();
/*
- * Start our win32 signal implementation. This has to be done
- * after we read the backend variables, because we need to pick
- * up the signal pipe from the parent process.
+ * Start our win32 signal implementation. This has to be done after we
+ * read the backend variables, because we need to pick up the signal pipe
+ * from the parent process.
*/
#ifdef WIN32
pgwin32_signal_initialize();
@@ -3247,10 +3226,11 @@ SubPostmasterMain(int argc, char *argv[])
CreateSharedMemoryAndSemaphores(false, 0);
#ifdef USE_SSL
+
/*
- * Need to reinitialize the SSL library in the backend,
- * since the context structures contain function pointers
- * and cannot be passed through the parameter file.
+ * Need to reinitialize the SSL library in the backend, since the
+ * context structures contain function pointers and cannot be passed
+ * through the parameter file.
*/
if (EnableSSL)
secure_initialize();
@@ -3304,8 +3284,8 @@ SubPostmasterMain(int argc, char *argv[])
if (strcmp(argv[1], "-forkcol") == 0)
{
/*
- * Do NOT close postmaster sockets here, because we are forking
- * from pgstat buffer process, which already did it.
+ * Do NOT close postmaster sockets here, because we are forking from
+ * pgstat buffer process, which already did it.
*/
/* Do not want to attach to shared memory */
@@ -3326,7 +3306,6 @@ SubPostmasterMain(int argc, char *argv[])
return 1; /* shouldn't get here */
}
-
#endif /* EXEC_BACKEND */
@@ -3341,8 +3320,8 @@ ExitPostmaster(int status)
/* should cleanup shared memory and kill all backends */
/*
- * Not sure of the semantics here. When the Postmaster dies, should
- * the backends all be killed? probably not.
+ * Not sure of the semantics here. When the Postmaster dies, should the
+ * backends all be killed? probably not.
*
* MUST -- vadim 05-10-1999
*/
@@ -3371,9 +3350,8 @@ sigusr1_handler(SIGNAL_ARGS)
if (CheckPostmasterSignal(PMSIGNAL_WAKEN_CHILDREN))
{
/*
- * Send SIGUSR1 to all children (triggers
- * CatchupInterruptHandler). See storage/ipc/sinval[adt].c for the
- * use of this.
+ * Send SIGUSR1 to all children (triggers CatchupInterruptHandler).
+ * See storage/ipc/sinval[adt].c for the use of this.
*/
if (Shutdown <= SmartShutdown)
{
@@ -3387,8 +3365,8 @@ sigusr1_handler(SIGNAL_ARGS)
PgArchPID != 0 && Shutdown == NoShutdown)
{
/*
- * Send SIGUSR1 to archiver process, to wake it up and begin
- * archiving next transaction log file.
+ * Send SIGUSR1 to archiver process, to wake it up and begin archiving
+ * next transaction log file.
*/
kill(PgArchPID, SIGUSR1);
}
@@ -3397,7 +3375,7 @@ sigusr1_handler(SIGNAL_ARGS)
SysLoggerPID != 0)
{
/* Tell syslogger to rotate logfile */
- kill(SysLoggerPID, SIGUSR1);
+ kill(SysLoggerPID, SIGUSR1);
}
PG_SETMASK(&UnBlockSig);
@@ -3459,9 +3437,9 @@ RandomSalt(char *cryptSalt, char *md5Salt)
* bytes, since only one of the two salts will be sent to the client.
* After that we need to compute more random bits.
*
- * We use % 255, sacrificing one possible byte value, so as to ensure
- * that all bits of the random() value participate in the result.
- * While at it, add one to avoid generating any null bytes.
+ * We use % 255, sacrificing one possible byte value, so as to ensure that
+ * all bits of the random() value participate in the result. While at it,
+ * add one to avoid generating any null bytes.
*/
md5Salt[0] = (rand % 255) + 1;
rand = PostmasterRandom();
@@ -3508,7 +3486,7 @@ CountChildren(void)
/*
* StartChildProcess -- start a non-backend child process for the postmaster
*
- * xlop determines what kind of child will be started. All child types
+ * xlop determines what kind of child will be started. All child types
* initially go to BootstrapMain, which will handle common setup.
*
* Return value of StartChildProcess is subprocess' PID, or 0 if failed
@@ -3548,8 +3526,7 @@ StartChildProcess(int xlop)
if (pid == 0) /* child */
{
- IsUnderPostmaster = true; /* we are a postmaster subprocess
- * now */
+ IsUnderPostmaster = true; /* we are a postmaster subprocess now */
/* Close the postmaster's sockets */
ClosePostmasterPorts(false);
@@ -3571,6 +3548,7 @@ StartChildProcess(int xlop)
{
/* in parent, fork failed */
int save_errno = errno;
+
errno = save_errno;
switch (xlop)
{
@@ -3580,7 +3558,7 @@ StartChildProcess(int xlop)
break;
case BS_XLOG_BGWRITER:
ereport(LOG,
- (errmsg("could not fork background writer process: %m")));
+ (errmsg("could not fork background writer process: %m")));
break;
default:
ereport(LOG,
@@ -3589,8 +3567,8 @@ StartChildProcess(int xlop)
}
/*
- * fork failure is fatal during startup, but there's no need to
- * choke immediately if starting other child types fails.
+ * fork failure is fatal during startup, but there's no need to choke
+ * immediately if starting other child types fails.
*/
if (xlop == BS_XLOG_STARTUP)
ExitPostmaster(1);
@@ -3648,26 +3626,26 @@ extern void *ShmemIndexAlloc;
extern LWLock *LWLockArray;
extern slock_t *ProcStructLock;
extern int pgStatSock;
-extern int pgStatPipe[2];
+extern int pgStatPipe[2];
#ifndef WIN32
#define write_inheritable_socket(dest, src, childpid) (*(dest) = (src))
#define read_inheritable_socket(dest, src) (*(dest) = *(src))
#else
-static void write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE child);
-static void write_inheritable_socket(InheritableSocket *dest, SOCKET src,
- pid_t childPid);
-static void read_inheritable_socket(SOCKET *dest, InheritableSocket *src);
+static void write_duplicated_handle(HANDLE * dest, HANDLE src, HANDLE child);
+static void write_inheritable_socket(InheritableSocket * dest, SOCKET src,
+ pid_t childPid);
+static void read_inheritable_socket(SOCKET * dest, InheritableSocket * src);
#endif
/* Save critical backend variables into the BackendParameters struct */
#ifndef WIN32
static bool
-save_backend_variables(BackendParameters *param, Port *port)
+save_backend_variables(BackendParameters * param, Port *port)
#else
static bool
-save_backend_variables(BackendParameters *param, Port *port,
+save_backend_variables(BackendParameters * param, Port *port,
HANDLE childProcess, pid_t childPid)
#endif
{
@@ -3726,9 +3704,9 @@ save_backend_variables(BackendParameters *param, Port *port,
* process instance of the handle to the parameter file.
*/
static void
-write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE childProcess)
+write_duplicated_handle(HANDLE * dest, HANDLE src, HANDLE childProcess)
{
- HANDLE hChild = INVALID_HANDLE_VALUE;
+ HANDLE hChild = INVALID_HANDLE_VALUE;
if (!DuplicateHandle(GetCurrentProcess(),
src,
@@ -3752,7 +3730,7 @@ write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE childProcess)
* straight socket inheritance.
*/
static void
-write_inheritable_socket(InheritableSocket *dest, SOCKET src, pid_t childpid)
+write_inheritable_socket(InheritableSocket * dest, SOCKET src, pid_t childpid)
{
dest->origsocket = src;
if (src != 0 && src != -1)
@@ -3769,11 +3747,11 @@ write_inheritable_socket(InheritableSocket *dest, SOCKET src, pid_t childpid)
* Read a duplicate socket structure back, and get the socket descriptor.
*/
static void
-read_inheritable_socket(SOCKET *dest, InheritableSocket *src)
+read_inheritable_socket(SOCKET * dest, InheritableSocket * src)
{
- SOCKET s;
+ SOCKET s;
- if (src->origsocket == -1 || src->origsocket == 0)
+ if (src->origsocket == -1 || src->origsocket == 0)
{
/* Not a real socket! */
*dest = src->origsocket;
@@ -3796,9 +3774,9 @@ read_inheritable_socket(SOCKET *dest, InheritableSocket *src)
*dest = s;
/*
- * To make sure we don't get two references to the same socket,
- * close the original one. (This would happen when inheritance
- * actually works..
+ * To make sure we don't get two references to the same socket, close
+ * the original one. (This would happen when inheritance actually
+ * works..
*/
closesocket(src->origsocket);
}
@@ -3812,7 +3790,7 @@ read_backend_variables(char *id, Port *port)
#ifndef WIN32
/* Non-win32 implementation reads from file */
- FILE *fp;
+ FILE *fp;
/* Open file */
fp = AllocateFile(id, PG_BINARY_R);
@@ -3840,10 +3818,10 @@ read_backend_variables(char *id, Port *port)
}
#else
/* Win32 version uses mapped file */
- HANDLE paramHandle;
+ HANDLE paramHandle;
BackendParameters *paramp;
- paramHandle = (HANDLE)atol(id);
+ paramHandle = (HANDLE) atol(id);
paramp = MapViewOfFile(paramHandle, FILE_MAP_READ, 0, 0, 0);
if (!paramp)
{
@@ -3874,7 +3852,7 @@ read_backend_variables(char *id, Port *port)
/* Restore critical backend variables from the BackendParameters struct */
static void
-restore_backend_variables(BackendParameters *param, Port *port)
+restore_backend_variables(BackendParameters * param, Port *port)
{
memcpy(port, &param->port, sizeof(Port));
read_inheritable_socket(&port->sock, &param->portsocket);
@@ -3975,7 +3953,6 @@ ShmemBackendArrayRemove(pid_t pid)
(errmsg_internal("could not find backend entry with pid %d",
(int) pid)));
}
-
#endif /* EXEC_BACKEND */
@@ -4059,7 +4036,7 @@ win32_waitpid(int *exitstatus)
case WAIT_FAILED:
ereport(LOG,
(errmsg_internal("failed to wait on %lu of %lu children: error code %d",
- num, win32_numChildren, (int) GetLastError())));
+ num, win32_numChildren, (int) GetLastError())));
return -1;
case WAIT_TIMEOUT:
@@ -4069,21 +4046,21 @@ win32_waitpid(int *exitstatus)
default:
/*
- * Get the exit code, and return the PID of, the
- * respective process
+ * Get the exit code, and return the PID of, the respective
+ * process
*/
index = offset + ret - WAIT_OBJECT_0;
Assert(index >= 0 && index < win32_numChildren);
if (!GetExitCodeProcess(win32_childHNDArray[index], &exitCode))
{
/*
- * If we get this far, this should never happen, but,
- * then again... No choice other than to assume a
- * catastrophic failure.
+ * If we get this far, this should never happen, but, then
+ * again... No choice other than to assume a catastrophic
+ * failure.
*/
ereport(FATAL,
- (errmsg_internal("failed to get exit code for child %lu",
- (unsigned long) win32_childPIDArray[index])));
+ (errmsg_internal("failed to get exit code for child %lu",
+ (unsigned long) win32_childPIDArray[index])));
}
*exitstatus = (int) exitCode;
return win32_childPIDArray[index];
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index e5aa153dd4..b2e3add6a8 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -18,7 +18,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.19 2005/08/12 03:23:51 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.20 2005/10/15 02:49:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -87,7 +87,6 @@ static char *last_file_name = NULL;
/* These must be exported for EXEC_BACKEND case ... annoying */
#ifndef WIN32
int syslogPipe[2] = {-1, -1};
-
#else
HANDLE syslogPipe[2] = {0, 0};
#endif
@@ -149,22 +148,21 @@ SysLoggerMain(int argc, char *argv[])
set_ps_display("");
/*
- * If we restarted, our stderr is already redirected into our own
- * input pipe. This is of course pretty useless, not to mention that
- * it interferes with detecting pipe EOF. Point stderr to /dev/null.
- * This assumes that all interesting messages generated in the
- * syslogger will come through elog.c and will be sent to
- * write_syslogger_file.
+ * If we restarted, our stderr is already redirected into our own input
+ * pipe. This is of course pretty useless, not to mention that it
+ * interferes with detecting pipe EOF. Point stderr to /dev/null. This
+ * assumes that all interesting messages generated in the syslogger will
+ * come through elog.c and will be sent to write_syslogger_file.
*/
if (redirection_done)
{
int fd = open(NULL_DEV, O_WRONLY);
/*
- * The closes might look redundant, but they are not: we want to
- * be darn sure the pipe gets closed even if the open failed. We
- * can survive running with stderr pointing nowhere, but we can't
- * afford to have extra pipe input descriptors hanging around.
+ * The closes might look redundant, but they are not: we want to be
+ * darn sure the pipe gets closed even if the open failed. We can
+ * survive running with stderr pointing nowhere, but we can't afford
+ * to have extra pipe input descriptors hanging around.
*/
close(fileno(stdout));
close(fileno(stderr));
@@ -174,9 +172,9 @@ SysLoggerMain(int argc, char *argv[])
}
/*
- * Also close our copy of the write end of the pipe. This is needed
- * to ensure we can detect pipe EOF correctly. (But note that in the
- * restart case, the postmaster already did this.)
+ * Also close our copy of the write end of the pipe. This is needed to
+ * ensure we can detect pipe EOF correctly. (But note that in the restart
+ * case, the postmaster already did this.)
*/
#ifndef WIN32
if (syslogPipe[1] >= 0)
@@ -191,9 +189,9 @@ SysLoggerMain(int argc, char *argv[])
/*
* Properly accept or ignore signals the postmaster might send us
*
- * Note: we ignore all termination signals, and instead exit only when
- * all upstream processes are gone, to ensure we don't miss any dying
- * gasps of broken backends...
+ * Note: we ignore all termination signals, and instead exit only when all
+ * upstream processes are gone, to ensure we don't miss any dying gasps of
+ * broken backends...
*/
pqsignal(SIGHUP, sigHupHandler); /* set flag to read config file */
@@ -202,7 +200,7 @@ SysLoggerMain(int argc, char *argv[])
pqsignal(SIGQUIT, SIG_IGN);
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
- pqsignal(SIGUSR1, sigUsr1Handler); /* request log rotation */
+ pqsignal(SIGUSR1, sigUsr1Handler); /* request log rotation */
pqsignal(SIGUSR2, SIG_IGN);
/*
@@ -253,8 +251,8 @@ SysLoggerMain(int argc, char *argv[])
ProcessConfigFile(PGC_SIGHUP);
/*
- * Check if the log directory or filename pattern changed in
- * postgresql.conf. If so, force rotation to make sure we're
+ * Check if the log directory or filename pattern changed in
+ * postgresql.conf. If so, force rotation to make sure we're
* writing the logfiles in the right place.
*/
if (strcmp(Log_directory, currentLogDir) != 0)
@@ -269,6 +267,7 @@ SysLoggerMain(int argc, char *argv[])
currentLogFilename = pstrdup(Log_filename);
rotation_requested = true;
}
+
/*
* If rotation time parameter changed, reset next rotation time,
* but don't immediately force a rotation.
@@ -316,7 +315,7 @@ SysLoggerMain(int argc, char *argv[])
if (errno != EINTR)
ereport(LOG,
(errcode_for_socket_access(),
- errmsg("select() failed in logger process: %m")));
+ errmsg("select() failed in logger process: %m")));
}
else if (rc > 0 && FD_ISSET(syslogPipe[0], &rfds))
{
@@ -328,7 +327,7 @@ SysLoggerMain(int argc, char *argv[])
if (errno != EINTR)
ereport(LOG,
(errcode_for_socket_access(),
- errmsg("could not read from logger pipe: %m")));
+ errmsg("could not read from logger pipe: %m")));
}
else if (bytesRead > 0)
{
@@ -338,11 +337,10 @@ SysLoggerMain(int argc, char *argv[])
else
{
/*
- * Zero bytes read when select() is saying read-ready
- * means EOF on the pipe: that is, there are no longer any
- * processes with the pipe write end open. Therefore, the
- * postmaster and all backends are shut down, and we are
- * done.
+ * Zero bytes read when select() is saying read-ready means
+ * EOF on the pipe: that is, there are no longer any processes
+ * with the pipe write end open. Therefore, the postmaster
+ * and all backends are shut down, and we are done.
*/
pipe_eof_seen = true;
}
@@ -350,9 +348,9 @@ SysLoggerMain(int argc, char *argv[])
#else /* WIN32 */
/*
- * On Windows we leave it to a separate thread to transfer data
- * and detect pipe EOF. The main thread just wakes up once a
- * second to check for SIGHUP and rotation conditions.
+ * On Windows we leave it to a separate thread to transfer data and
+ * detect pipe EOF. The main thread just wakes up once a second to
+ * check for SIGHUP and rotation conditions.
*/
pgwin32_backend_usleep(1000000);
#endif /* WIN32 */
@@ -364,10 +362,10 @@ SysLoggerMain(int argc, char *argv[])
/*
* Normal exit from the syslogger is here. Note that we
- * deliberately do not close syslogFile before exiting; this
- * is to allow for the possibility of elog messages being
- * generated inside proc_exit. Regular exit() will take care
- * of flushing and closing stdio channels.
+ * deliberately do not close syslogFile before exiting; this is to
+ * allow for the possibility of elog messages being generated
+ * inside proc_exit. Regular exit() will take care of flushing
+ * and closing stdio channels.
*/
proc_exit(0);
}
@@ -390,13 +388,13 @@ SysLogger_Start(void)
* If first time through, create the pipe which will receive stderr
* output.
*
- * If the syslogger crashes and needs to be restarted, we continue to use
- * the same pipe (indeed must do so, since extant backends will be
- * writing into that pipe).
+ * If the syslogger crashes and needs to be restarted, we continue to use the
+ * same pipe (indeed must do so, since extant backends will be writing
+ * into that pipe).
*
- * This means the postmaster must continue to hold the read end of the
- * pipe open, so we can pass it down to the reincarnated syslogger.
- * This is a bit klugy but we have little choice.
+ * This means the postmaster must continue to hold the read end of the pipe
+ * open, so we can pass it down to the reincarnated syslogger. This is a
+ * bit klugy but we have little choice.
*/
#ifndef WIN32
if (syslogPipe[0] < 0)
@@ -404,7 +402,7 @@ SysLogger_Start(void)
if (pgpipe(syslogPipe) < 0)
ereport(FATAL,
(errcode_for_socket_access(),
- (errmsg("could not create pipe for syslog: %m"))));
+ (errmsg("could not create pipe for syslog: %m"))));
}
#else
if (!syslogPipe[0])
@@ -418,7 +416,7 @@ SysLogger_Start(void)
if (!CreatePipe(&syslogPipe[0], &syslogPipe[1], &sa, 32768))
ereport(FATAL,
(errcode_for_file_access(),
- (errmsg("could not create pipe for syslog: %m"))));
+ (errmsg("could not create pipe for syslog: %m"))));
}
#endif
@@ -428,8 +426,8 @@ SysLogger_Start(void)
mkdir(Log_directory, 0700);
/*
- * The initial logfile is created right in the postmaster, to verify
- * that the Log_directory is writable.
+ * The initial logfile is created right in the postmaster, to verify that
+ * the Log_directory is writable.
*/
filename = logfile_getname(time(NULL));
@@ -730,9 +728,9 @@ logfile_rotate(bool time_based_rotation)
rotation_requested = false;
/*
- * When doing a time-based rotation, invent the new logfile name based
- * on the planned rotation time, not current time, to avoid "slippage"
- * in the file name when we don't do the rotation immediately.
+ * When doing a time-based rotation, invent the new logfile name based on
+ * the planned rotation time, not current time, to avoid "slippage" in the
+ * file name when we don't do the rotation immediately.
*/
if (time_based_rotation)
filename = logfile_getname(next_rotation_time);
@@ -742,14 +740,14 @@ logfile_rotate(bool time_based_rotation)
/*
* Decide whether to overwrite or append. We can overwrite if (a)
* Log_truncate_on_rotation is set, (b) the rotation was triggered by
- * elapsed time and not something else, and (c) the computed file name
- * is different from what we were previously logging into.
+ * elapsed time and not something else, and (c) the computed file name is
+ * different from what we were previously logging into.
*
* Note: during the first rotation after forking off from the postmaster,
* last_file_name will be NULL. (We don't bother to set it in the
- * postmaster because it ain't gonna work in the EXEC_BACKEND case.)
- * So we will always append in that situation, even though truncating
- * would usually be safe.
+ * postmaster because it ain't gonna work in the EXEC_BACKEND case.) So we
+ * will always append in that situation, even though truncating would
+ * usually be safe.
*/
if (Log_truncate_on_rotation && time_based_rotation &&
last_file_name != NULL && strcmp(filename, last_file_name) != 0)
@@ -767,15 +765,15 @@ logfile_rotate(bool time_based_rotation)
filename)));
/*
- * ENFILE/EMFILE are not too surprising on a busy system; just
- * keep using the old file till we manage to get a new one.
- * Otherwise, assume something's wrong with Log_directory and stop
- * trying to create files.
+ * ENFILE/EMFILE are not too surprising on a busy system; just keep
+ * using the old file till we manage to get a new one. Otherwise,
+ * assume something's wrong with Log_directory and stop trying to
+ * create files.
*/
if (saveerrno != ENFILE && saveerrno != EMFILE)
{
ereport(LOG,
- (errmsg("disabling automatic rotation (use SIGHUP to reenable)")));
+ (errmsg("disabling automatic rotation (use SIGHUP to reenable)")));
Log_RotationAge = 0;
Log_RotationSize = 0;
}
@@ -828,7 +826,7 @@ logfile_getname(pg_time_t timestamp)
tm = pg_localtime(&timestamp, global_timezone);
pg_strftime(filename + len, MAXPGPATH - len, Log_filename, tm);
}
- else
+ else
{
/* no strftime escapes, so append timestamp to new filename */
snprintf(filename + len, MAXPGPATH - len, "%s.%lu",
@@ -855,10 +853,10 @@ set_next_rotation_time(void)
/*
* The requirements here are to choose the next time > now that is a
* "multiple" of the log rotation interval. "Multiple" can be interpreted
- * fairly loosely. In this version we align to local time rather than
+ * fairly loosely. In this version we align to local time rather than
* GMT.
*/
- rotinterval = Log_RotationAge * SECS_PER_MINUTE; /* convert to seconds */
+ rotinterval = Log_RotationAge * SECS_PER_MINUTE; /* convert to seconds */
now = time(NULL);
tm = pg_localtime(&now, global_timezone);
now += tm->tm_gmtoff;