aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/basebackup.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2015-01-17 13:00:42 +0100
committerAndres Freund <andres@anarazel.de>2015-01-17 13:00:42 +0100
commitff44fba46c09c37dd9e60da1cb0b3a9339eb085f (patch)
treec7200c94c36c93da2284087d1d645618994e1935 /src/backend/replication/basebackup.c
parent20af53d7191f84d0f5b86da4362e481b7e85d52a (diff)
downloadpostgresql-ff44fba46c09c37dd9e60da1cb0b3a9339eb085f.tar.gz
postgresql-ff44fba46c09c37dd9e60da1cb0b3a9339eb085f.zip
Replace walsender's latch with the general shared latch.
Relying on the normal shared latch simplifies interrupt/signal handling because we can rely on all signal handlers setting the proc latch. That in turn allows us to avoid the use of ImmediateInterruptOK, which arguably isn't correct because WaitLatchOrSocket isn't declared to be immediately interruptible. Also change sections that wait on the walsender's latch to notice interrupts quicker/more reliably and make them more consistent with each other. This is part of a larger "get rid of ImmediateInterruptOK" series. Discussion: 20150115020335.GZ5245@awork2.anarazel.de
Diffstat (limited to 'src/backend/replication/basebackup.c')
-rw-r--r--src/backend/replication/basebackup.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 07030a2ef08..3058ce921b0 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -1294,15 +1294,21 @@ throttle(size_t increment)
/* Only sleep if the transfer is faster than it should be. */
if (sleep > 0)
{
- ResetLatch(&MyWalSnd->latch);
+ ResetLatch(MyLatch);
+
+ /* We're eating a potentially set latch, so check for interrupts */
+ CHECK_FOR_INTERRUPTS();
/*
* (TAR_SEND_SIZE / throttling_sample * elapsed_min_unit) should be
* the maximum time to sleep. Thus the cast to long is safe.
*/
- wait_result = WaitLatch(&MyWalSnd->latch,
+ wait_result = WaitLatch(MyLatch,
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
(long) (sleep / 1000));
+
+ if (wait_result & WL_LATCH_SET)
+ CHECK_FOR_INTERRUPTS();
}
else
{