mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-01 10:41:18 +02:00
Allow condition variables to be used in interrupt code.
Adjust the condition variable sleep loop to work correctly when code reached by its internal CHECK_FOR_INTERRUPTS() call interacts with another condition variable. There are no such cases currently, but a proposed patch would do this. Discussion: https://postgr.es/m/CA+hUKGLdemy2gBm80kz20GTe6hNVwoErE8KwcJk6-U56oStjtg@mail.gmail.com
This commit is contained in:
parent
814f1d8bc3
commit
f5a5773a9d
@ -165,8 +165,6 @@ ConditionVariableTimedSleep(ConditionVariable *cv, long timeout,
|
|||||||
/* Reset latch before examining the state of the wait list. */
|
/* Reset latch before examining the state of the wait list. */
|
||||||
ResetLatch(MyLatch);
|
ResetLatch(MyLatch);
|
||||||
|
|
||||||
CHECK_FOR_INTERRUPTS();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this process has been taken out of the wait list, then we know
|
* If this process has been taken out of the wait list, then we know
|
||||||
* that it has been signaled by ConditionVariableSignal (or
|
* that it has been signaled by ConditionVariableSignal (or
|
||||||
@ -190,6 +188,15 @@ ConditionVariableTimedSleep(ConditionVariable *cv, long timeout,
|
|||||||
}
|
}
|
||||||
SpinLockRelease(&cv->mutex);
|
SpinLockRelease(&cv->mutex);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for interrupts, and return spuriously if that caused the
|
||||||
|
* current sleep target to change (meaning that interrupt handler code
|
||||||
|
* waited for a different condition variable).
|
||||||
|
*/
|
||||||
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
if (cv != cv_sleep_target)
|
||||||
|
done = true;
|
||||||
|
|
||||||
/* We were signaled, so return */
|
/* We were signaled, so return */
|
||||||
if (done)
|
if (done)
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user