Skip to content

Commit

Permalink
Merge e64c3cc into 26de0ab
Browse files Browse the repository at this point in the history
  • Loading branch information
maltoe committed Mar 25, 2015
2 parents 26de0ab + e64c3cc commit bd3df60
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/redlock/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ def lock_instances(resource, ttl)
value = SecureRandom.uuid

locked, time_elapsed = timed do
@servers.select { |s| s.lock(resource, value, ttl) }
@servers.select { |s| s.lock(resource, value, ttl) }.size
end

validity = ttl - time_elapsed - drift(ttl)

if locked.size >= @quorum && validity >= 0
if locked >= @quorum && validity >= 0
{ validity: validity, resource: resource, value: value }
else
locked.each { |s| s.unlock(resource, value) }
@servers.each { |s| s.unlock(resource, value) }
false
end
end
Expand Down

0 comments on commit bd3df60

Please sign in to comment.