Skip to content

Commit 2dc7c88

Browse files
committed
On some platforms, pg_usleep isn't interruptible by signals; fix
archiver to behave per original coder's expectation on these machines. We already know this everywhere else AFAICT.
1 parent 6d54320 commit 2dc7c88

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/backend/postmaster/pgarch.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.24 2006/06/27 22:16:43 momjian Exp $
22+
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.25 2006/08/07 17:41:42 tgl Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -286,7 +286,6 @@ static void
286286
pgarch_MainLoop(void)
287287
{
288288
time_t last_copy_time = 0;
289-
time_t curtime;
290289

291290
/*
292291
* We run the copy loop immediately upon entry, in case there are
@@ -298,7 +297,6 @@ pgarch_MainLoop(void)
298297

299298
do
300299
{
301-
302300
/* Check for config update */
303301
if (got_SIGHUP)
304302
{
@@ -318,15 +316,19 @@ pgarch_MainLoop(void)
318316

319317
/*
320318
* There shouldn't be anything for the archiver to do except to wait
321-
* for a signal, ... however, the archiver exists to protect our data,
322-
* so she wakes up occasionally to allow herself to be proactive. In
323-
* particular this avoids getting stuck if a signal arrives just
324-
* before we sleep.
319+
* for a signal ... however, the archiver exists to protect our data,
320+
* so she wakes up occasionally to allow herself to be proactive.
321+
*
322+
* On some platforms, signals won't interrupt the sleep. To ensure we
323+
* respond reasonably promptly when someone signals us, break down the
324+
* sleep into 1-second increments, and check for interrupts after each
325+
* nap.
325326
*/
326-
if (!wakened)
327+
while (!(wakened || got_SIGHUP))
327328
{
328-
pg_usleep(PGARCH_AUTOWAKE_INTERVAL * 1000000L);
329+
time_t curtime;
329330

331+
pg_usleep(1000000L);
330332
curtime = time(NULL);
331333
if ((unsigned int) (curtime - last_copy_time) >=
332334
(unsigned int) PGARCH_AUTOWAKE_INTERVAL)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy