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

View File

@ -3229,7 +3229,8 @@ again:
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);