Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
belenios
belenios
Commits
3c24ae96
Commit
3c24ae96
authored
Jun 30, 2013
by
Stephane Glondu
Browse files
Use a shared mutex in cast and update_cred
parent
3d1e773e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/web/web_common.ml
View file @
3c24ae96
...
...
@@ -185,7 +185,7 @@ module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struc
)
)
let
cast
rawballot
(
user
,
date
)
=
let
do_
cast
rawballot
(
user
,
date
)
=
let
voting_open
=
match
P
.
metadata
with
|
Some
m
->
let
date
=
fst
date
in
...
...
@@ -273,7 +273,7 @@ module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struc
let
turnout
=
Ocsipersist
.
length
ballot_table
let
update_cred
~
old
~
new_
=
let
do_
update_cred
~
old
~
new_
=
match_lwt
Ocsipersist
.
fold_step
(
fun
k
v
x
->
if
sha256_hex
k
=
old
then
(
match
v
with
...
...
@@ -285,6 +285,15 @@ module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struc
|
Some
x
->
Ocsipersist
.
remove
cred_table
x
>>
Ocsipersist
.
add
cred_table
new_
None
let
mutex
=
Lwt_mutex
.
create
()
let
cast
rawballot
(
user
,
date
)
=
Lwt_mutex
.
with_lock
mutex
(
fun
()
->
do_cast
rawballot
(
user
,
date
))
let
update_cred
~
old
~
new_
=
Lwt_mutex
.
with_lock
mutex
(
fun
()
->
do_update_cred
~
old
~
new_
)
end
module
type
WEB_ELECTION
=
sig
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment