Browse Source

mutex lazy resolution

Simon Krajewski 3 months ago
parent
commit
3a9e075ae1
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/context/common.ml

+ 7 - 0
src/context/common.ml

@@ -1099,14 +1099,21 @@ let get_entry_point com =
 
 
 let make_unforced_lazy t_proc f where =
 let make_unforced_lazy t_proc f where =
 	let r = ref (lazy_available t_dynamic) in
 	let r = ref (lazy_available t_dynamic) in
+	let m = Mutex.create () in
 	r := lazy_wait (fun() ->
 	r := lazy_wait (fun() ->
 		try
 		try
+			Mutex.lock m;
 			r := lazy_processing t_proc;
 			r := lazy_processing t_proc;
 			let t = f () in
 			let t = f () in
 			r := lazy_available t;
 			r := lazy_available t;
+			Mutex.unlock m;
 			t
 			t
 		with
 		with
 			| Error.Error e ->
 			| Error.Error e ->
+				Mutex.unlock m;
 				raise (Error.Fatal_error e)
 				raise (Error.Fatal_error e)
+			| exc ->
+				Mutex.unlock m;
+				raise exc
 	);
 	);
 	r
 	r