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

fix: pass O_SHARE_DELETE when digesting files #8262

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Unreleased
- Improve `dune describe external-lib-deps` by adding the internal dependencies
for more information. (#7478, @moyodiallo)

- Re-enable background file digests on Windows. The files are now open in a way
that prevents race condition around deletion. (#8262, fixes #8268, @emillon)

3.9.2 (2023-07-25)
------------------

Expand Down
5 changes: 1 addition & 4 deletions src/dune_config/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ let background_digests =
let t =
{ name = "background_digests"
; of_string = Toggle.of_string
; value =
(match Platform.OS.value with
| Linux -> `Enabled
| _ -> `Disabled)
; value = background_default
}
in
register t;
Expand Down
6 changes: 5 additions & 1 deletion src/dune_digest/dune_digest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ end

module Direct_impl : Digest_impl = struct
let file file =
(* On Windows, if this function is invoked in a background thread,
if can happen that the file is not properly closed.
[O_SHARE_DELETE] ensures that the main thread can delete it even if it
is still open. See #8243. *)
let fd =
match Unix.openfile file [ Unix.O_RDONLY ] 0 with
match Unix.openfile file [ Unix.O_RDONLY; O_SHARE_DELETE ] 0 with
emillon marked this conversation as resolved.
Show resolved Hide resolved
| fd -> fd
| exception Unix.Unix_error (Unix.EACCES, _, _) ->
raise (Sys_error (sprintf "%s: Permission denied" file))
Expand Down
Loading