Browse Source

fix with timers in server mode

Nicolas Cannasse 13 năm trước cách đây
mục cha
commit
a53dc92ff1
2 tập tin đã thay đổi với 7 bổ sung10 xóa
  1. 3 2
      common.ml
  2. 4 8
      main.ml

+ 3 - 2
common.ml

@@ -241,7 +241,8 @@ let timer name =
 	curtime := t :: !curtime;
 	(function() -> close t)
 
-let rec close_time() =
+let rec close_times() =
 	match !curtime with
 	| [] -> ()
-	| t :: _ -> close t
+	| t :: _ -> close t; close_times()
+

+ 4 - 8
main.ml

@@ -496,12 +496,13 @@ and wait_loop boot_com host port =
 				Common.default_print := ssend sin;
 				Parser.resume_display := Ast.null_pos;
 				measure_times := false;
+				close_times();
 				Hashtbl.clear Common.htimers;
-				let other = Common.timer "other" in
+				let _ = Common.timer "other" in
 				Hashtbl.clear modules_added;
 				start_time := get_time();
 				process_params flush [] data;
-				other();
+				close_times();
 				if !measure_times then report_times (fun s -> ssend sin (s ^ "\n"))
 			with Completion str ->
 				if verbose then print_endline ("Completion Response =\n" ^ str);
@@ -923,12 +924,7 @@ with
 		let ctx = Type.print_context() in
 		let fields = List.map (fun (name,t,doc) -> name, Type.s_type ctx t, (match doc with None -> "" | Some d -> d)) fields in
 		let fields = if !measure_times then begin
-			let rec loop() =
-				match !curtime with
-				| [] -> ()
-				| _ -> close_time(); loop();
-			in
-			loop();
+			close_times();
 			let tot = ref 0. in
 			Hashtbl.iter (fun _ t -> tot := !tot +. t.total) Common.htimers;
 			let fields = ("@TOTAL", Printf.sprintf "%.3fs" (get_time() -. !start_time), "") :: fields in