Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit number of simultaneously opened fds #578

Merged
2 commits merged into from
Mar 8, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Limit number of simultaneously opened fds
Non-optimal solution: only handles the common case.
dra27 committed Mar 3, 2018
commit e30fa83a17783c02c40579c207c9235bac08210c
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@ next

- Ignore errors during the generation of the .merlin (#569, fixes #568 and #51)

- Reduce the number of simultaneously opened fds (#578)

1.0+beta18 (25/02/2018)
-----------------------

18 changes: 15 additions & 3 deletions src/action.ml
Original file line number Diff line number Diff line change
@@ -702,7 +702,7 @@ type exec_context =
; env : string array
}

let exec_run ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args =
let exec_run_direct ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args =
begin match ectx.context with
| None
| Some { Context.for_host = None; _ } -> ()
@@ -717,13 +717,16 @@ let exec_run ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args =
invalid_prefix ("_build/" ^ target.name);
invalid_prefix ("_build/install/" ^ target.name);
end;
let stdout_to = get_std_output stdout_to in
let stderr_to = get_std_output stderr_to in
let env = Context.extend_env ~vars:env_extra ~env:ectx.env in
Process.run Strict ~dir:(Path.to_string dir) ~env ~stdout_to ~stderr_to
~purpose:ectx.purpose
(Path.reach_for_running ~from:dir prog) args

let exec_run ~stdout_to ~stderr_to =
let stdout_to = get_std_output stdout_to in
let stderr_to = get_std_output stderr_to in
exec_run_direct ~stdout_to ~stderr_to

let exec_echo stdout_to str =
Fiber.return
(match stdout_to with
@@ -744,6 +747,15 @@ let rec exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to =
| Redirect (Stdout, fn, Echo s) ->
Io.write_file (Path.to_string fn) s;
Fiber.return ()
| Redirect (outputs, fn, Run (Ok prog, args)) ->
let out = Process.File (Path.to_string fn) in
let stdout_to, stderr_to =
match outputs with
| Stdout -> (out, get_std_output stderr_to)
| Stderr -> (get_std_output stdout_to, out)
| Outputs -> (out, out)
in
exec_run_direct ~ectx ~dir ~env_extra ~stdout_to ~stderr_to prog args
| Redirect (outputs, fn, t) ->
redirect ~ectx ~dir outputs fn t ~env_extra ~stdout_to ~stderr_to
| Ignore (outputs, t) ->