Attention une mise à jour du service Gitlab va être effectuée le mardi 14 décembre entre 13h30 et 14h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 3c24ae96 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Use a shared mutex in cast and update_cred

parent 3d1e773e
...@@ -185,7 +185,7 @@ module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struc ...@@ -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 let voting_open = match P.metadata with
| Some m -> | Some m ->
let date = fst date in let date = fst date in
...@@ -273,7 +273,7 @@ module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struc ...@@ -273,7 +273,7 @@ module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struc
let turnout = Ocsipersist.length ballot_table 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 -> match_lwt Ocsipersist.fold_step (fun k v x ->
if sha256_hex k = old then ( if sha256_hex k = old then (
match v with match v with
...@@ -285,6 +285,15 @@ module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struc ...@@ -285,6 +285,15 @@ module MakeBallotBox (P : Signatures.ELECTION_PARAMS) (E : LWT_ELECTION) = struc
| Some x -> | Some x ->
Ocsipersist.remove cred_table x >> Ocsipersist.remove cred_table x >>
Ocsipersist.add cred_table new_ None 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 end
module type WEB_ELECTION = sig module type WEB_ELECTION = sig
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment