summaryrefslogtreecommitdiff
path: root/src/backend/postmaster
diff options
context:
space:
mode:
authorTom Lane2008-02-17 02:09:32 +0000
committerTom Lane2008-02-17 02:09:32 +0000
commitcd004067742ee16ee63e55abfb4acbd5f09fbaab (patch)
tree62995d45f55faf5f5cdddc791d4d83d3de495b03 /src/backend/postmaster
parentee7a6770f607e9e7f0e1b29dc25a7b7d63cb7940 (diff)
Replace time_t with pg_time_t (same values, but always int64) in on-disk
data structures and backend internal APIs. This solves problems we've seen recently with inconsistent layout of pg_control between machines that have 32-bit time_t and those that have already migrated to 64-bit time_t. Also, we can get out from under the problem that Windows' Unix-API emulation is not consistent about the width of time_t. There are a few remaining places where local time_t variables are used to hold the current or recent result of time(NULL). I didn't bother changing these since they do not affect any cross-module APIs and surely all platforms will have 64-bit time_t before overflow becomes an actual risk. time_t should be avoided for anything visible to extension modules, however.
Diffstat (limited to 'src/backend/postmaster')
-rw-r--r--src/backend/postmaster/bgwriter.c22
-rw-r--r--src/backend/postmaster/syslogger.c4
2 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
index 10586b8fad2..5dce3fa6989 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.48 2008/01/01 19:45:51 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.49 2008/02/17 02:09:27 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -163,12 +163,12 @@ static bool am_bg_writer = false;
static bool ckpt_active = false;
/* these values are valid when ckpt_active is true: */
-static time_t ckpt_start_time;
+static pg_time_t ckpt_start_time;
static XLogRecPtr ckpt_start_recptr;
static double ckpt_cached_elapsed;
-static time_t last_checkpoint_time;
-static time_t last_xlog_switch_time;
+static pg_time_t last_checkpoint_time;
+static pg_time_t last_xlog_switch_time;
/* Prototypes for private functions */
@@ -250,7 +250,7 @@ BackgroundWriterMain(void)
/*
* Initialize so that first time-driven event happens at the correct time.
*/
- last_checkpoint_time = last_xlog_switch_time = time(NULL);
+ last_checkpoint_time = last_xlog_switch_time = (pg_time_t) time(NULL);
/*
* Create a resource owner to keep track of our resources (currently only
@@ -361,7 +361,7 @@ BackgroundWriterMain(void)
{
bool do_checkpoint = false;
int flags = 0;
- time_t now;
+ pg_time_t now;
int elapsed_secs;
/*
@@ -407,7 +407,7 @@ BackgroundWriterMain(void)
* occurs without an external request, but we set the CAUSE_TIME flag
* bit even if there is also an external request.
*/
- now = time(NULL);
+ now = (pg_time_t) time(NULL);
elapsed_secs = now - last_checkpoint_time;
if (elapsed_secs >= CheckPointTimeout)
{
@@ -504,13 +504,13 @@ BackgroundWriterMain(void)
static void
CheckArchiveTimeout(void)
{
- time_t now;
- time_t last_time;
+ pg_time_t now;
+ pg_time_t last_time;
if (XLogArchiveTimeout <= 0)
return;
- now = time(NULL);
+ now = (pg_time_t) time(NULL);
/* First we do a quick check using possibly-stale local state. */
if ((int) (now - last_xlog_switch_time) < XLogArchiveTimeout)
@@ -730,7 +730,7 @@ IsCheckpointOnSchedule(double progress)
* Check progress against time elapsed and checkpoint_timeout.
*/
gettimeofday(&now, NULL);
- elapsed_time = ((double) (now.tv_sec - ckpt_start_time) +
+ elapsed_time = ((double) ((pg_time_t) now.tv_sec - ckpt_start_time) +
now.tv_usec / 1000000.0) / CheckPointTimeout;
if (progress < elapsed_time)
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index aa5d34ef5b2..91bf56225a1 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.44 2008/01/25 20:42:10 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.45 2008/02/17 02:09:27 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -331,7 +331,7 @@ SysLoggerMain(int argc, char *argv[])
if (!rotation_requested && Log_RotationAge > 0)
{
/* Do a logfile rotation if it's time */
- pg_time_t now = time(NULL);
+ pg_time_t now = (pg_time_t) time(NULL);
if (now >= next_rotation_time)
rotation_requested = time_based_rotation = true;