Permalink
Browse files

Share lock: more accurate livelock fix for aa598f4

Awaken waiting threads even if the current thread (the previously
exclusive thread) hadn't taken a share lock.

This only happens in code that wasn't run within an executor, since that
always take an outermost share lock.
  • Loading branch information...
jeremy committed Apr 24, 2016
1 parent 24b1bb1 commit 65b6496ee4cf62be4c43ff21572e03a5e9cedac1
Showing with 2 additions and 3 deletions.
  1. +2 −3 activesupport/lib/active_support/concurrency/share_lock.rb
@@ -69,7 +69,6 @@ def stop_exclusive(compatible: [])
if eligible_waiters?(compatible)
yield_shares(compatible: compatible, block_share: true) do
@cv.broadcast
@cv.wait_while { @exclusive_thread || eligible_waiters?(compatible) }
end
end
@@ -145,9 +144,9 @@ def yield_shares(purpose: nil, compatible: [], block_share: false)
end
compatible |= [false] unless block_share
@waiting[Thread.current] = [purpose, compatible]
@cv.broadcast
end
@cv.broadcast
end
begin

0 comments on commit 65b6496

Please sign in to comment.