diff options
Diffstat (limited to 'sys/kern/kern_umtx.c')
-rw-r--r-- | sys/kern/kern_umtx.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 595e869..7a621fb 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -2831,7 +2831,7 @@ do_rw_rdlock(struct thread *td, struct urwlock *rwlock, long fflag, struct _umtx uint32_t flags, wrflags; int32_t state, oldstate; int32_t blocked_readers; - int error, rv; + int error, error1, rv; uq = td->td_umtxq; error = fueword32(&rwlock->rw_flags, &flags); @@ -2965,9 +2965,12 @@ sleep: suword32(&rwlock->rw_blocked_readers, blocked_readers-1); if (blocked_readers == 1) { rv = fueword32(&rwlock->rw_state, &state); - if (rv == -1) + if (rv == -1) { + umtxq_unbusy_unlocked(&uq->uq_key); error = EFAULT; - while (error == 0) { + break; + } + for (;;) { rv = casueword32(&rwlock->rw_state, state, &oldstate, state & ~URWLOCK_READ_WAITERS); if (rv == -1) { @@ -2977,7 +2980,12 @@ sleep: if (oldstate == state) break; state = oldstate; - error = umtxq_check_susp(td); + error1 = umtxq_check_susp(td); + if (error1 != 0) { + if (error == 0) + error = error1; + break; + } } } @@ -3000,7 +3008,7 @@ do_rw_wrlock(struct thread *td, struct urwlock *rwlock, struct _umtx_time *timeo int32_t state, oldstate; int32_t blocked_writers; int32_t blocked_readers; - int error, rv; + int error, error1, rv; uq = td->td_umtxq; error = fueword32(&rwlock->rw_flags, &flags); @@ -3146,14 +3154,17 @@ sleep: if (oldstate == state) break; state = oldstate; - error = umtxq_check_susp(td); + error1 = umtxq_check_susp(td); /* * We are leaving the URWLOCK_WRITE_WAITERS * behind, but this should not harm the * correctness. */ - if (error != 0) + if (error1 != 0) { + if (error == 0) + error = error1; break; + } } rv = fueword32(&rwlock->rw_blocked_readers, &blocked_readers); @@ -3344,7 +3355,6 @@ do_sem_wake(struct thread *td, struct _usem *sem) umtxq_busy(&key); cnt = umtxq_count(&key); if (cnt > 0) { - umtxq_signal(&key, 1); /* * Check if count is greater than 0, this means the memory is * still being referenced by user code, so we can safely @@ -3357,6 +3367,7 @@ do_sem_wake(struct thread *td, struct _usem *sem) if (error == -1) error = EFAULT; } + umtxq_signal(&key, 1); } umtxq_unbusy(&key); umtxq_unlock(&key); |