Skip to content

Commit

Permalink
Don't use the asynchronous run_process API if scheduler isn't running.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Mar 27, 2017
1 parent b0be82d commit 8422a7c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lang/lang_builtins.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ let () =
in
(timed_out, !status))
in
on_done (if 0. <= timeout then asynchronous() else synchronous ()))
on_done (if 0. <= timeout && Tutils.has_started() then asynchronous() else synchronous ()))

let () =
let ret_t = Lang.list_t (Lang.product_t Lang.string_t Lang.string_t) in
Expand Down
11 changes: 10 additions & 1 deletion src/tools/tutils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ type priority =

let scheduler = Duppy.create ()

let started = ref false

let started_m = Mutex.create ()

let has_started = mutexify started_m (fun () ->
!started)

let () =
let name = "Duppy scheduler shutdown" in
let f () =
Expand Down Expand Up @@ -239,7 +246,9 @@ let () =
new_queue
~priorities:(fun x -> x = Non_blocking)
~name ()
done))
done;
mutexify started_m (fun () ->
started := true) ()))

(** Replace stdout/err by a pipe, and install a Duppy task that pulls data
* out of that pipe and logs it.
Expand Down
1 change: 1 addition & 0 deletions src/tools/tutils.mli
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
raises an exception. *)
val create : ('a -> unit) -> 'a -> string -> Thread.t
val main : unit -> unit
val has_started : unit -> bool
val shutdown : unit -> unit

(** Special exception allowed for "clean" termination of Tutils threads.
Expand Down

0 comments on commit 8422a7c

Please sign in to comment.