Skip to content

Commit

Permalink
Hopefully fix flapping semaphore test
Browse files Browse the repository at this point in the history
There was a race condition on the $released variable. $t6 released the
semaphore and only then set the $released variable to 1. It's possible that
$t5 ackquired the semaphore and checked the $released variable between this
release and set. So the test would fail because $released was still 0.
First set the variable and then release the semaphore to fix the race.
  • Loading branch information
niner committed Mar 20, 2018
1 parent a2f6656 commit 68164ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion t/concurrency/03-semaphore.t
Expand Up @@ -60,8 +60,8 @@ my class Semaphore is repr('Semaphore') { }
}, 0);
my $t6 := nqp::newthread({
nqp::sleep(3.0);
nqp::semrelease($s);
$released := 1;
nqp::semrelease($s);
}, 0);

# First, exhaust semaphore capacity
Expand Down

0 comments on commit 68164ca

Please sign in to comment.