ck_bytelock: Fix downgrade path from writer to reader.

An off-by-one was introduced in downgrade path from writer.
This can cause deadlock if a writer downgrades from a write lock.

Pointed out by Jeffrey Birnbaum <jmb...@...>.
ck_pring
Samy Al Bahra 12 years ago
parent c4149c72b4
commit d29ac5afdb

@ -124,7 +124,7 @@ ck_bytelock_read_lock(struct ck_bytelock *bytelock, unsigned int slot)
{
if (ck_pr_load_uint(&bytelock->owner) == slot) {
ck_pr_store_8(&bytelock->readers[slot], true);
ck_pr_store_8(&bytelock->readers[slot - 1], true);
ck_pr_fence_strict_store();
ck_pr_store_uint(&bytelock->owner, 0);
return;

Loading…
Cancel
Save