cargo/Cargo.toml

63 lines
1.1 KiB
TOML
Raw Normal View History

2014-07-16 00:51:49 +00:00
[project]
name = "cargo"
2016-03-03 19:12:10 +00:00
version = "0.10.0"
2014-07-16 00:51:49 +00:00
authors = ["Yehuda Katz <wycats@gmail.com>",
2014-11-13 23:08:17 +00:00
"Carl Lerche <me@carllerche.com>",
"Alex Crichton <alex@alexcrichton.com>"]
license = "MIT/Apache-2.0"
homepage = "https://crates.io"
repository = "https://github.com/rust-lang/cargo"
documentation = "http://doc.crates.io/cargo"
description = """
Cargo, a package manager for Rust.
"""
2014-07-16 00:51:49 +00:00
2014-08-16 20:00:46 +00:00
[lib]
2014-07-16 00:51:49 +00:00
name = "cargo"
path = "src/cargo/lib.rs"
2014-12-19 03:01:37 +00:00
[dependencies]
advapi32-sys = "0.1"
2016-04-14 17:04:23 +00:00
crates-io = { path = "src/crates-io", version = "0.2" }
crossbeam = "0.2"
curl = "0.2"
docopt = "0.6"
2015-03-26 18:17:44 +00:00
env_logger = "0.3"
filetime = "0.1"
flate2 = "0.2"
Fix running Cargo concurrently Cargo has historically had no protections against running it concurrently. This is pretty unfortunate, however, as it essentially just means that you can only run one instance of Cargo at a time **globally on a system**. An "easy solution" to this would be the use of file locks, except they need to be applied judiciously. It'd be a pretty bad experience to just lock the entire system globally for Cargo (although it would work), but otherwise Cargo must be principled how it accesses the filesystem to ensure that locks are properly held. This commit intends to solve all of these problems. A new utility module is added to cargo, `util::flock`, which contains two types: * `FileLock` - a locked version of a `File`. This RAII guard will unlock the lock on `Drop` and I/O can be performed through this object. The actual underlying `Path` can be read from this object as well. * `Filesystem` - an unlocked representation of a `Path`. There is no "safe" method to access the underlying path without locking a file on the filesystem first. Built on the [fs2] library, these locks use the `flock` system call on Unix and `LockFileEx` on Windows. Although file locking on Unix is [documented as not so great][unix-bad], but largely only because of NFS, these are just advisory, and there's no byte-range locking. These issues don't necessarily plague Cargo, however, so we should try to leverage them. On both Windows and Unix the file locks are released when the underlying OS handle is closed, which means that if the process dies the locks are released. Cargo has a number of global resources which it now needs to lock, and the strategy is done in a fairly straightforward way: * Each registry's index contains one lock (a dotfile in the index). Updating the index requires a read/write lock while reading the index requires a shared lock. This should allow each process to ensure a registry update happens while not blocking out others for an unnecessarily long time. Additionally any number of processes can read the index. * When downloading crates, each downloaded crate is individually locked. A lock for the downloaded crate implies a lock on the output directory as well. Because downloaded crates are immutable, once the downloaded directory exists the lock is no longer needed as it won't be modified, so it can be released. This granularity of locking allows multiple Cargo instances to download dependencies in parallel. * Git repositories have separate locks for the database and for the project checkout. The datbase and checkout are locked for read/write access when an update is performed, and the lock of the checkout is held for the entire lifetime of the git source. This is done to ensure that any other Cargo processes must wait while we use the git repository. Unfortunately there's just not that much parallelism here. * Binaries managed by `cargo install` are locked by the local metadata file that Cargo manages. This is relatively straightforward. * The actual artifact output directory is just globally locked for the entire build. It's hypothesized that running Cargo concurrently in *one directory* is less of a feature needed rather than running multiple instances of Cargo globally (for now at least). It would be possible to have finer grained locking here, but that can likely be deferred to a future PR. So with all of this infrastructure in place, Cargo is now ready to grab some locks and ensure that you can call it concurrently anywhere at any time and everything always works out as one might expect. One interesting question, however, is what does Cargo do on contention? On one hand Cargo could immediately abort, but this would lead to a pretty poor UI as any Cargo process on the system could kick out any other. Instead this PR takes a more nuanced approach. * First, all locks are attempted to be acquired (a "try lock"). If this succeeds, we're done. * Next, Cargo prints a message to the console that it's going to block waiting for a lock. This is done because it's indeterminate how long Cargo will wait for the lock to become available, and most long-lasting operations in Cargo have a message printed for them. * Finally, a blocking acquisition of the lock is issued and we wait for it to become available. So all in all this should help Cargo fix any future concurrency bugs with file locking in a principled fashion while also allowing concurrent Cargo processes to proceed reasonably across the system. [fs2]: https://github.com/danburkert/fs2-rs [unix-bad]: http://0pointer.de/blog/projects/locking.html Closes #354
2016-03-12 17:58:53 +00:00
fs2 = "0.2"
git2 = "0.4"
git2-curl = "0.4"
glob = "0.2"
kernel32-sys = "0.2"
libc = "0.2"
libgit2-sys = "0.4"
log = "0.3"
num_cpus = "0.2"
regex = "0.1"
rustc-serialize = "0.3"
2016-02-01 20:12:17 +00:00
semver = "0.2.2"
tar = "0.4"
term = "0.4.4"
time = "0.1"
toml = "0.1"
url = "0.2"
winapi = "0.2"
[dev-dependencies]
tempdir = "0.3"
hamcrest = "0.1"
bufstream = "0.1"
filetime = "0.1"
2014-07-16 00:51:49 +00:00
[[bin]]
name = "cargo"
test = false
2014-08-14 21:54:56 +00:00
doc = false
2014-07-16 00:51:49 +00:00
[[test]]
name = "tests"
[[test]]
name = "resolve"