mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 08:33:39 +08:00
Use DistributedMutex to make sure poll votes are tallied correctly.
This commit is contained in:
parent
56ee1ac569
commit
63b96da63a
|
@ -143,15 +143,17 @@ module ::PollPlugin
|
||||||
return if is_closed?
|
return if is_closed?
|
||||||
|
|
||||||
# Get the user's current vote.
|
# Get the user's current vote.
|
||||||
vote = get_vote(user)
|
DistributedMutex.new(details_key).synchronize do
|
||||||
vote = nil unless details.keys.include? vote
|
vote = get_vote(user)
|
||||||
|
vote = nil unless details.keys.include? vote
|
||||||
|
|
||||||
new_details = details.dup
|
new_details = details.dup
|
||||||
new_details[vote] -= 1 if vote
|
new_details[vote] -= 1 if vote
|
||||||
new_details[option] += 1
|
new_details[option] += 1
|
||||||
|
|
||||||
::PluginStore.set("poll", vote_key(user), option)
|
::PluginStore.set("poll", vote_key(user), option)
|
||||||
set_details! new_details
|
set_details! new_details
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize(user)
|
def serialize(user)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user