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

Commitda99cce

Browse files
committed
Avoid delaying postmaster shutdown by up to 10 seconds on platforms
where signals do not terminate sleep() delays.
1 parent4a1c29f commitda99cce

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.159 2004/02/1215:06:56 wieck Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.160 2004/02/1220:07:26 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -943,6 +943,7 @@ BufferBackgroundWriter(void)
943943
for (;;)
944944
{
945945
intn;
946+
longudelay;
946947

947948
/*
948949
* Call BufferSync() with instructions to keep just the
@@ -970,8 +971,23 @@ BufferBackgroundWriter(void)
970971
/*
971972
* Nap for the configured time or sleep for 10 seconds if
972973
* there was nothing to do at all.
974+
*
975+
* On some platforms, signals won't interrupt the sleep. To ensure
976+
* we respond reasonably promptly when the postmaster signals us,
977+
* break down the sleep into 1-second increments, and check for
978+
* interrupts after each nap.
973979
*/
974-
pg_usleep((n>0) ?BgWriterDelay*1000L :10000000L);
980+
udelay= ((n>0) ?BgWriterDelay :10000)*1000L;
981+
while (udelay>1000000L)
982+
{
983+
pg_usleep(1000000L);
984+
udelay-=1000000L;
985+
if (InterruptPending)
986+
return;
987+
}
988+
pg_usleep(udelay);
989+
if (InterruptPending)
990+
return;
975991
}
976992
}
977993

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp