Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38cc085

Browse files
committed
Simplify main waiting loop of the archiver process
As coded, the timeout given to WaitLatch() was always equal toPGARCH_AUTOWAKE_INTERVAL, as time() was called two times repeatedly.This simplification could have been done ind75288f.While on it, this adjusts a comment in pgarch.c to describe the archiverin a more neutral way.Author: Sravan Kumar, Nathan BossartReviewed-by: Kyotaro HoriguchiDiscussion:https://postgr.es/m/CA+=NbjjqYE9-Lnw7H7DAiS5jebmoMikwZQb_sBP7kgBCn9q6Hg@mail.gmail.com
1 parentfbed4bc commit38cc085

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

‎src/backend/postmaster/pgarch.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,12 @@ pgarch_waken_stop(SIGNAL_ARGS)
297297
staticvoid
298298
pgarch_MainLoop(void)
299299
{
300-
pg_time_tlast_copy_time=0;
301300
booltime_to_stop;
302301

303302
/*
304303
* There shouldn't be anything for the archiver to do except to wait for a
305-
* signal ... however, the archiver exists to protect our data, soshe
306-
* wakes up occasionally to allowherself to be proactive.
304+
* signal ... however, the archiver exists to protect our data, soit
305+
* wakes up occasionally to allowitself to be proactive.
307306
*/
308307
do
309308
{
@@ -335,30 +334,21 @@ pgarch_MainLoop(void)
335334

336335
/* Do what we're here for */
337336
pgarch_ArchiverCopyLoop();
338-
last_copy_time=time(NULL);
339337

340338
/*
341339
* Sleep until a signal is received, or until a poll is forced by
342-
* PGARCH_AUTOWAKE_INTERVAL having passed since last_copy_time, or
343-
* until postmaster dies.
340+
* PGARCH_AUTOWAKE_INTERVAL, or until postmaster dies.
344341
*/
345342
if (!time_to_stop)/* Don't wait during last iteration */
346343
{
347-
pg_time_tcurtime= (pg_time_t)time(NULL);
348-
inttimeout;
349-
350-
timeout=PGARCH_AUTOWAKE_INTERVAL- (curtime-last_copy_time);
351-
if (timeout>0)
352-
{
353-
intrc;
354-
355-
rc=WaitLatch(MyLatch,
356-
WL_LATCH_SET |WL_TIMEOUT |WL_POSTMASTER_DEATH,
357-
timeout*1000L,
358-
WAIT_EVENT_ARCHIVER_MAIN);
359-
if (rc&WL_POSTMASTER_DEATH)
360-
time_to_stop= true;
361-
}
344+
intrc;
345+
346+
rc=WaitLatch(MyLatch,
347+
WL_LATCH_SET |WL_TIMEOUT |WL_POSTMASTER_DEATH,
348+
PGARCH_AUTOWAKE_INTERVAL*1000L,
349+
WAIT_EVENT_ARCHIVER_MAIN);
350+
if (rc&WL_POSTMASTER_DEATH)
351+
time_to_stop= true;
362352
}
363353

364354
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp