1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-27 08:00:11 +00:00

Fix handling of transient casueword(9) failures in do_sem_wait().

In particular, restart should be only done when the failure is
transient.  For this, recheck the count1 value after the operation.

Note that do_sem_wait() is older usem interface.

Reported and tested by:	bdrewery
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2019-07-31 19:16:49 +00:00
parent 3b3dd3f770
commit fd336e2ac0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=350478

View File

@ -3229,7 +3229,8 @@ do_sem_wait(struct thread *td, struct _usem *sem, struct _umtx_time *timeout)
rv = casueword32(&sem->_has_waiters, 0, &count1, 1);
if (rv == 0)
rv1 = fueword32(&sem->_count, &count);
if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) || rv == 1) {
if (rv == -1 || (rv == 0 && (rv1 == -1 || count != 0)) ||
(rv == 1 && count1 == 0)) {
umtxq_lock(&uq->uq_key);
umtxq_unbusy(&uq->uq_key);
umtxq_remove(uq);