• Tom Lane's avatar
    Fix WaitLatch() to return promptly when the requested timeout expires. · 3e7fdcff
    Tom Lane authored
    If the sleep is interrupted by a signal, we must recompute the remaining
    time to wait; otherwise, a steady stream of non-wait-terminating interrupts
    could delay return from WaitLatch indefinitely.  This has been shown to be
    a problem for the autovacuum launcher, and there may well be other places
    now or in the future with similar issues.  So we'd better make the function
    robust, even though this'll add at least one gettimeofday call per wait.
    
    Back-patch to 9.2.  We might eventually need to fix 9.1 as well, but the
    code is quite different there, and the usage of WaitLatch in 9.1 is so
    limited that it's not clearly important to do so.
    
    Reported and diagnosed by Jeff Janes, though I rewrote his patch rather
    heavily.
    3e7fdcff
latch.h 5.28 KB