Skip to content

Commit

Permalink
Use scoped thread provided by standard library (#1703)
Browse files Browse the repository at this point in the history
* Use scoped thread provided by standard library

* Fix unwrap and error mapping location
  • Loading branch information
tottoto authored Mar 30, 2023
1 parent a2d1009 commit a45064c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ zip = { version = "0.6", default-features = false }
zstd = "0.12"

# dist-server only
crossbeam-utils = { version = "0.8", optional = true }
nix = { version = "0.26.2", optional = true }
rouille = { version = "3.5", optional = true, default-features = false, features = ["ssl"] }
syslog = { version = "6", optional = true }
Expand Down Expand Up @@ -136,7 +135,7 @@ unstable = []
# Enables distributed support in the sccache client
dist-client = ["flate2", "hyper", "reqwest", "url", "sha2"]
# Enables the sccache-dist binary
dist-server = ["crossbeam-utils", "jwt", "flate2", "libmount", "nix", "openssl", "reqwest", "rouille", "syslog", "void", "version-compare"]
dist-server = ["jwt", "flate2", "libmount", "nix", "openssl", "reqwest", "rouille", "syslog", "void", "version-compare"]
# Enables dist tests with external requirements
dist-tests = ["dist-client", "dist-server"]

Expand Down
6 changes: 2 additions & 4 deletions src/bin/sccache-dist/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ impl OverlayBuilder {
compile_command.arguments
);

crossbeam_utils::thread::scope(|scope| {
std::thread::scope(|scope| {
scope
.spawn(|_| {
.spawn(|| {
// Now mounted filesystems will be automatically unmounted when this thread dies
// (and tmpfs filesystems will be completely destroyed)
nix::sched::unshare(nix::sched::CloneFlags::CLONE_NEWNS)
Expand Down Expand Up @@ -410,13 +410,11 @@ impl OverlayBuilder {
output: compile_output,
outputs,
})

// Bizarrely there's no way to actually get any information from a thread::Result::Err
})
.join()
.unwrap_or_else(|_e| Err(anyhow!("Build thread exited unsuccessfully")))
})
.unwrap_or_else(|e| Err(anyhow!("Error joining build thread: {:?}", e)))
}

// Failing during cleanup is pretty unexpected, but we can still return the successful compile
Expand Down

0 comments on commit a45064c

Please sign in to comment.