mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-01 04:12:51 +00:00
Set waiters flag before checking semaphore's counter,
otherwise we might lose a wakeup. Tested on postgresql database server.
This commit is contained in:
parent
530a5fb294
commit
93f0162799
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=203657
@ -2853,6 +2853,8 @@ do_sem_wait(struct thread *td, struct _usem *sem, struct timespec *timeout)
|
||||
umtxq_insert(uq);
|
||||
umtxq_unlock(&uq->uq_key);
|
||||
|
||||
suword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 1);
|
||||
|
||||
count = fuword32(__DEVOLATILE(uint32_t *, &sem->_count));
|
||||
if (count != 0) {
|
||||
umtxq_lock(&uq->uq_key);
|
||||
@ -2863,11 +2865,6 @@ do_sem_wait(struct thread *td, struct _usem *sem, struct timespec *timeout)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* set waiters byte and sleep.
|
||||
*/
|
||||
suword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 1);
|
||||
|
||||
umtxq_lock(&uq->uq_key);
|
||||
umtxq_unbusy(&uq->uq_key);
|
||||
umtxq_unlock(&uq->uq_key);
|
||||
|
Loading…
Reference in New Issue
Block a user