Skip to content
Snippets Groups Projects
Commit f9270e93 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[kernel] lock only log listeners on rec

parent 8a29480c
No related branches found
No related tags found
No related merge requests found
...@@ -419,17 +419,7 @@ let check_not_yet = ref (fun _evt -> false) ...@@ -419,17 +419,7 @@ let check_not_yet = ref (fun _evt -> false)
(* --- Listeners --- *) (* --- Listeners --- *)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
let firelock = ref false let do_fire e f = f e
let do_fire e f =
if !firelock then f e else
try
firelock := true ;
f e ;
firelock := false
with exn ->
firelock := false ;
raise exn
let iter_kind ?kind f ems = let iter_kind ?kind f ems =
match kind with match kind with
...@@ -490,6 +480,8 @@ let logtransient channel text = ...@@ -490,6 +480,8 @@ let logtransient channel text =
raise e raise e
) buffer text ) buffer text
let locked_listeners = ref false
let logwithfinal finally channel let logwithfinal finally channel
?(fire=true) (* fire channel listeners *) ?(fire=true) (* fire channel listeners *)
?emitwith (* additional emitter *) ?emitwith (* additional emitter *)
...@@ -528,8 +520,16 @@ let logwithfinal finally channel ...@@ -528,8 +520,16 @@ let logwithfinal finally channel
if echo && e.echo then if echo && e.echo then
do_echo channel.terminal event ; do_echo channel.terminal event ;
Extlib.may (do_fire event) emitwith; Extlib.may (do_fire event) emitwith;
if fire && not !firelock then if fire && not !locked_listeners then
List.iter (do_fire event) e.listeners ; begin
try
locked_listeners := true ;
List.iter (do_fire event) e.listeners ;
locked_listeners := false ;
with exn ->
locked_listeners := false ;
raise exn
end ;
Some event Some event
end end
else None else None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment