Skip to content

Commit 572eaf2

Browse files
committed
Auto merge of #7201 - alexcrichton:revert-thing, r=ehuss
Revert "Release a jobserver token while locking a file" This reverts commit d19b41f. Discovered in #7200 this is just a straight up recipe for deadlock. One Cargo has a jobserver token and wants a file lock. Another Cargo has the file lock and wants a jobserver token. If we had a way to acquire a jobserver token in a nonblocking fashion we could perhaps solve this, but for now I think it's best to revert to the previous behavior. Closes #7200
2 parents 85b9566 + 20d9119 commit 572eaf2

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/cargo/util/flock.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -321,27 +321,8 @@ fn acquire(
321321
let msg = format!("waiting for file lock on {}", msg);
322322
config.shell().status_with_color("Blocking", &msg, Cyan)?;
323323

324-
// We're about to block the current process and not really do anything
325-
// productive for what could possibly be a very long time. We could be
326-
// waiting, for example, on another Cargo to finish a download, finish an
327-
// entire build, etc. Since we're not doing anything productive we're not
328-
// making good use of our jobserver token, if we have one.
329-
//
330-
// This can typically come about if `cargo` is invoked from `make` (or some
331-
// other jobserver-providing system). In this situation it's actually best
332-
// if we release the token back to the original jobserver to let some other
333-
// cpu-hungry work continue to make progress. After we're done blocking
334-
// we'll block waiting to reacquire a token as we'll probably be doing cpu
335-
// hungry work ourselves.
336-
let jobserver = config.jobserver_from_env();
337-
if let Some(server) = jobserver {
338-
server.release_raw()?;
339-
}
340-
let result = block().chain_err(|| format!("failed to lock file: {}", path.display()));
341-
if let Some(server) = jobserver {
342-
server.acquire_raw()?;
343-
}
344-
return Ok(result?);
324+
block().chain_err(|| format!("failed to lock file: {}", path.display()))?;
325+
return Ok(());
345326

346327
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
347328
fn is_on_nfs_mount(path: &Path) -> bool {

0 commit comments

Comments
 (0)