diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/pg_prewarm/autoprewarm.c | 12 | ||||
-rw-r--r-- | contrib/postgres_fdw/connection.c | 9 |
2 files changed, 7 insertions, 14 deletions
diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c index 3bd0010bf8b..fcbdbdd0279 100644 --- a/contrib/pg_prewarm/autoprewarm.c +++ b/contrib/pg_prewarm/autoprewarm.c @@ -226,18 +226,16 @@ autoprewarm_main(Datum main_arg) } else { - long delay_in_ms = 0; - TimestampTz next_dump_time = 0; - long secs = 0; - int usecs = 0; + TimestampTz next_dump_time; + long delay_in_ms; /* Compute the next dump time. */ next_dump_time = TimestampTzPlusMilliseconds(last_dump_time, autoprewarm_interval * 1000); - TimestampDifference(GetCurrentTimestamp(), next_dump_time, - &secs, &usecs); - delay_in_ms = secs + (usecs / 1000); + delay_in_ms = + TimestampDifferenceMilliseconds(GetCurrentTimestamp(), + next_dump_time); /* Perform a dump if it's time. */ if (delay_in_ms <= 0) diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c index fed14eb85d1..3cac70e39e5 100644 --- a/contrib/postgres_fdw/connection.c +++ b/contrib/postgres_fdw/connection.c @@ -1139,20 +1139,15 @@ pgfdw_get_cleanup_result(PGconn *conn, TimestampTz endtime, PGresult **result) { int wc; TimestampTz now = GetCurrentTimestamp(); - long secs; - int microsecs; long cur_timeout; /* If timeout has expired, give up, else get sleep time. */ - if (now >= endtime) + cur_timeout = TimestampDifferenceMilliseconds(now, endtime); + if (cur_timeout <= 0) { timed_out = true; goto exit; } - TimestampDifference(now, endtime, &secs, µsecs); - - /* To protect against clock skew, limit sleep to one minute. */ - cur_timeout = Min(60000, secs * USECS_PER_SEC + microsecs); /* Sleep until there's something to do */ wc = WaitLatchOrSocket(MyLatch, |