mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
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
This commit is contained in:
@ -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
|
||||
{
|
||||
|
Reference in New Issue
Block a user