[proc locker] minor cleanup

Summary: Remove custom exception and no-op `clean`.

Reviewed By: jvillard

Differential Revision: D25397729

fbshipit-source-id: e76fd103b
master
Nikos Gorogiannis 4 years ago committed by Facebook GitHub Bot
parent 75d2674a45
commit 7e79b4826f

@ -187,7 +187,6 @@ let analyze source_files_to_analyze =
~tasks:build_tasks_generator ~tasks:build_tasks_generator
in in
let workers_stats = Tasks.Runner.run runner in let workers_stats = Tasks.Runner.run runner in
RestartScheduler.clean () ;
let collected_stats = let collected_stats =
Array.fold workers_stats ~init:([], []) Array.fold workers_stats ~init:([], [])
~f:(fun ((backend_stats_list, gc_stats_list) as stats_list) stats_opt -> ~f:(fun ((backend_stats_list, gc_stats_list) as stats_list) stats_opt ->

@ -7,8 +7,6 @@
open! IStd open! IStd
exception UnlockNotLocked of Procname.t
let log_lock_time = BackendStats.add_to_proc_locker_lock_time let log_lock_time = BackendStats.add_to_proc_locker_lock_time
let log_unlock_time = BackendStats.add_to_proc_locker_unlock_time let log_unlock_time = BackendStats.add_to_proc_locker_unlock_time
@ -31,8 +29,6 @@ let setup () =
create_file locks_target create_file locks_target
let clean () = ()
let lock_of_filename filename = locks_dir ^/ filename let lock_of_filename filename = locks_dir ^/ filename
let lock_of_procname pname = lock_of_filename (Procname.to_filename pname) let lock_of_procname pname = lock_of_filename (Procname.to_filename pname)
@ -40,7 +36,8 @@ let lock_of_procname pname = lock_of_filename (Procname.to_filename pname)
let unlock pname = let unlock pname =
record_time_of ~log_f:log_unlock_time ~f:(fun () -> record_time_of ~log_f:log_unlock_time ~f:(fun () ->
try Unix.unlink (lock_of_procname pname) try Unix.unlink (lock_of_procname pname)
with Unix.Unix_error (Unix.ENOENT, _, _) -> raise (UnlockNotLocked pname) ) with Unix.Unix_error (Unix.ENOENT, _, _) ->
Die.die InternalError "Tried to unlock not-locked pname: %a@\n" Procname.pp pname )
let try_lock pname = let try_lock pname =

@ -7,8 +7,6 @@
open! IStd open! IStd
exception UnlockNotLocked of Procname.t
val setup : unit -> unit val setup : unit -> unit
(** This should be called once before trying to lock Anything. *) (** This should be called once before trying to lock Anything. *)
@ -19,8 +17,4 @@ val unlock : Procname.t -> unit
(** This will work as a cleanup function because after calling unlock all the workers that need an (** This will work as a cleanup function because after calling unlock all the workers that need an
unlocked Proc should find it's summary already Cached. Throws if the lock had not been taken. *) unlocked Proc should find it's summary already Cached. Throws if the lock had not been taken. *)
val clean : unit -> unit
(** This should be called when locks will no longer be used to remove any files or state that's not
necessary. *)
val is_locked : proc_filename:string -> bool val is_locked : proc_filename:string -> bool

@ -127,5 +127,3 @@ let unlock pname =
let setup () = if_restart_scheduler ProcLocker.setup let setup () = if_restart_scheduler ProcLocker.setup
let clean () = if_restart_scheduler ProcLocker.clean

@ -8,8 +8,6 @@ open! IStd
val setup : unit -> unit val setup : unit -> unit
val clean : unit -> unit
val lock_exn : Procname.t -> unit val lock_exn : Procname.t -> unit
val unlock : Procname.t -> unit val unlock : Procname.t -> unit

@ -30,7 +30,10 @@ let tests_wrapper _test_ctxt =
(* When an unlock is performed over a non-locked Procname it fails *) (* When an unlock is performed over a non-locked Procname it fails *)
try_lock a_pname |> ignore ; try_lock a_pname |> ignore ;
unlock a_pname ; unlock a_pname ;
assert_raises (UnlockNotLocked a_pname) (fun () -> unlock a_pname)) try
unlock a_pname ;
assert_failure "Should have raised an exception."
with Die.InferInternalError _ -> ())
let tests = "restart_scheduler_suite" >:: tests_wrapper let tests = "restart_scheduler_suite" >:: tests_wrapper

Loading…
Cancel
Save