Browse Source

Account for the jobserver implicit token

Make sure we don't accidentally deadlock ourselves by acquiring too many
tokens!
master
Alex Crichton 5 years ago
parent
commit
238ee4f093
  1. 12
      src/lib.rs

12
src/lib.rs

@ -977,6 +977,7 @@ impl Build {
// possible as soon as any compilation fails to ensure that errors get
// out to the user as fast as possible.
let server = jobserver();
server.release_raw()?; // release our process's token which we'll reacquire in the loop
let error = AtomicBool::new(false);
let mut threads = Vec::new();
for obj in objs {
@ -1008,6 +1009,10 @@ impl Build {
}
}
// Reacquire our process's token before we proceed, which we released
// before entering the loop above.
server.release_raw()?;
return Ok(());
/// Shared state from the parent thread to the child thread. This
@ -1053,7 +1058,12 @@ impl Build {
parallelism = amt;
}
}
jobserver::Client::new(parallelism).expect("failed to create jobserver")
// If we create our own jobserver then be sure to reserve one token
// for ourselves.
let client = jobserver::Client::new(parallelism).expect("failed to create jobserver");
client.acquire_raw().expect("failed to acquire initial");
return client;
}
struct JoinOnDrop(Option<thread::JoinHandle<Result<(), Error>>>);

Loading…
Cancel
Save