mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 14:25:49 +00:00
Bug 1806766 - Update jobserver to 0.1.25. r=emilio,supply-chain-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D165469
This commit is contained in:
parent
994fa36b7b
commit
5fbb5ec3fe
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -2747,9 +2747,9 @@ checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.24"
|
||||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
|
||||
checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
@ -999,6 +999,11 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "1.0.3 -> 1.0.5"
|
||||
|
||||
[[audits.jobserver]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.1.24 -> 0.1.25"
|
||||
|
||||
[[audits.libc]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
@ -1 +1 @@
|
||||
{"files":{"Cargo.toml":"9d5e9bc3aa927124431914287d2830ff03ca5a80931a3b44b3f057b92d09e850","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"07d8d79f8f6b6a94321fe8db78d26ed409de47cee49290947bd6bbfa29d05e9c","src/lib.rs":"891d9c9cf2d75eee30c02ffa8ae7fa8fb1f7675dccddb0cc79a067e1a87a9850","src/unix.rs":"5802f031e80295c5498a2ddb95b5ee6e39b7294f25b35075302fb978b8d4c409","src/wasm.rs":"bb67f97bccd0b0c1762917de342d721e319a3a204604ab1517285c59b5e2a369","src/windows.rs":"f886175abbf75ff45ea3fc09396bbcc3048e7daf732ed78149377f7b8e9148b2","tests/client-of-myself.rs":"ca09bf398f69df4bac1730999e954dbbc3faf3c6512678c136e0938e7e9cd0ab","tests/client.rs":"64547b780edce5ebcd397db1160fd86baab030c530c6976fa013bca9f07a85ff","tests/helper.rs":"c0e6c00eaf849295d8ec23e374690b6645c0f7d993e91abf7ad53ac960f71762","tests/make-as-a-client.rs":"ec09a7cdbf78d6c3b16f26de15766c4bd62d44a913ada6b86b66e067e6c484ba","tests/server.rs":"9a260f1302ae4908479df0bd34b46edb9d2b8b9b3dbc3e2b6666296d9e1b2b84"},"package":"af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"}
|
||||
{"files":{"Cargo.toml":"8bdb529d87cf3cd9eed1909a2f32216ea34caa2f30ac552f57cb29a1bdad5568","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"07d8d79f8f6b6a94321fe8db78d26ed409de47cee49290947bd6bbfa29d05e9c","src/lib.rs":"4e841d58f95ea5f5cd4f975d0ddefaeef4dc364717cda16d6f0b908850b31ab8","src/unix.rs":"68b089c8c96ee0f8ac867db66520f0bd05cb6ed818f9f3c06aa1a079c9379aec","src/wasm.rs":"65d3d8ed45972b4459581505906481d32a50d2f7514cd7ff2a595fceeaa672f0","src/windows.rs":"8e0fa3ab29757d809d4fa03c8101870435ce8c4ceaebe491df3144d62fe0aaaf","tests/client-of-myself.rs":"ca09bf398f69df4bac1730999e954dbbc3faf3c6512678c136e0938e7e9cd0ab","tests/client.rs":"d4745cdd650c86d19bc81f6c9b35df498996deffb86ae6412ad040af96a19183","tests/helper.rs":"c0e6c00eaf849295d8ec23e374690b6645c0f7d993e91abf7ad53ac960f71762","tests/make-as-a-client.rs":"8be1f3fef1e9e65c7904dbaa04364bf0f44e9deab84a2a247a5a94b5cf0df9bc","tests/server.rs":"da15bf12e1df1883f660892b996c9e0d92485aace3f7b50ee70c4a8e6deae8da"},"package":"068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b"}
|
22
third_party/rust/jobserver/Cargo.toml
vendored
22
third_party/rust/jobserver/Cargo.toml
vendored
@ -3,21 +3,23 @@
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "jobserver"
|
||||
version = "0.1.24"
|
||||
version = "0.1.25"
|
||||
authors = ["Alex Crichton <alex@alexcrichton.com>"]
|
||||
description = "An implementation of the GNU make jobserver for Rust\n"
|
||||
description = """
|
||||
An implementation of the GNU make jobserver for Rust
|
||||
"""
|
||||
homepage = "https://github.com/alexcrichton/jobserver-rs"
|
||||
documentation = "https://docs.rs/jobserver"
|
||||
readme = "README.md"
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/alexcrichton/jobserver-rs"
|
||||
|
||||
@ -43,19 +45,21 @@ harness = false
|
||||
[[test]]
|
||||
name = "helper"
|
||||
path = "tests/helper.rs"
|
||||
|
||||
[dev-dependencies.futures]
|
||||
version = "0.1"
|
||||
|
||||
[dev-dependencies.num_cpus]
|
||||
version = "1.0"
|
||||
|
||||
[dev-dependencies.tempdir]
|
||||
version = "0.3"
|
||||
[dev-dependencies.tempfile]
|
||||
version = "3"
|
||||
|
||||
[dev-dependencies.tokio-core]
|
||||
version = "0.1"
|
||||
|
||||
[dev-dependencies.tokio-process]
|
||||
version = "0.2"
|
||||
|
||||
[target."cfg(unix)".dependencies.libc]
|
||||
version = "0.2.50"
|
||||
|
49
third_party/rust/jobserver/src/lib.rs
vendored
49
third_party/rust/jobserver/src/lib.rs
vendored
@ -208,7 +208,7 @@ impl Client {
|
||||
/// with `CLOEXEC` so they're not automatically inherited by spawned
|
||||
/// children.
|
||||
///
|
||||
/// # Unsafety
|
||||
/// # Safety
|
||||
///
|
||||
/// This function is `unsafe` to call on Unix specifically as it
|
||||
/// transitively requires usage of the `from_raw_fd` function, which is
|
||||
@ -273,6 +273,19 @@ impl Client {
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns amount of tokens in the read-side pipe.
|
||||
///
|
||||
/// # Return value
|
||||
///
|
||||
/// Number of bytes available to be read from the jobserver pipe
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Underlying errors from the ioctl will be passed up.
|
||||
pub fn available(&self) -> io::Result<usize> {
|
||||
self.inner.available()
|
||||
}
|
||||
|
||||
/// Configures a child process to have access to this client's jobserver as
|
||||
/// well.
|
||||
///
|
||||
@ -290,13 +303,41 @@ impl Client {
|
||||
///
|
||||
/// On platforms other than Unix and Windows this panics.
|
||||
pub fn configure(&self, cmd: &mut Command) {
|
||||
cmd.env("CARGO_MAKEFLAGS", &self.mflags_env());
|
||||
self.inner.configure(cmd);
|
||||
}
|
||||
|
||||
/// Configures a child process to have access to this client's jobserver as
|
||||
/// well.
|
||||
///
|
||||
/// This function is required to be called to ensure that a jobserver is
|
||||
/// properly inherited to a child process. If this function is *not* called
|
||||
/// then this `Client` will not be accessible in the child process. In other
|
||||
/// words, if not called, then `Client::from_env` will return `None` in the
|
||||
/// child process (or the equivalent of `Child::from_env` that `make` uses).
|
||||
///
|
||||
/// ## Platform-specific behavior
|
||||
///
|
||||
/// On Unix and Windows this will clobber the `CARGO_MAKEFLAGS`,
|
||||
/// `MAKEFLAGS` and `MFLAGS` environment variables for the child process,
|
||||
/// and on Unix this will also allow the two file descriptors for
|
||||
/// this client to be inherited to the child.
|
||||
///
|
||||
/// On platforms other than Unix and Windows this panics.
|
||||
pub fn configure_make(&self, cmd: &mut Command) {
|
||||
let value = self.mflags_env();
|
||||
cmd.env("CARGO_MAKEFLAGS", &value);
|
||||
cmd.env("MAKEFLAGS", &value);
|
||||
cmd.env("MFLAGS", &value);
|
||||
self.inner.configure(cmd);
|
||||
}
|
||||
|
||||
fn mflags_env(&self) -> String {
|
||||
let arg = self.inner.string_arg();
|
||||
// Older implementations of make use `--jobserver-fds` and newer
|
||||
// implementations use `--jobserver-auth`, pass both to try to catch
|
||||
// both implementations.
|
||||
let value = format!("-j --jobserver-fds={0} --jobserver-auth={0}", arg);
|
||||
cmd.env("CARGO_MAKEFLAGS", &value);
|
||||
self.inner.configure(cmd);
|
||||
format!("-j --jobserver-fds={0} --jobserver-auth={0}", arg)
|
||||
}
|
||||
|
||||
/// Converts this `Client` into a helper thread to deal with a blocking
|
||||
|
35
third_party/rust/jobserver/src/unix.rs
vendored
35
third_party/rust/jobserver/src/unix.rs
vendored
@ -1,7 +1,9 @@
|
||||
use libc::c_int;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::mem;
|
||||
use std::mem::MaybeUninit;
|
||||
use std::os::unix::prelude::*;
|
||||
use std::process::Command;
|
||||
use std::ptr;
|
||||
@ -21,13 +23,24 @@ pub struct Acquired {
|
||||
}
|
||||
|
||||
impl Client {
|
||||
pub fn new(limit: usize) -> io::Result<Client> {
|
||||
pub fn new(mut limit: usize) -> io::Result<Client> {
|
||||
let client = unsafe { Client::mk()? };
|
||||
|
||||
// I don't think the character written here matters, but I could be
|
||||
// wrong!
|
||||
for _ in 0..limit {
|
||||
(&client.write).write_all(&[b'|'])?;
|
||||
const BUFFER: [u8; 128] = [b'|'; 128];
|
||||
|
||||
set_nonblocking(client.write.as_raw_fd(), true)?;
|
||||
|
||||
while limit > 0 {
|
||||
let n = limit.min(BUFFER.len());
|
||||
|
||||
(&client.write).write_all(&BUFFER[..n])?;
|
||||
limit -= n;
|
||||
}
|
||||
|
||||
set_nonblocking(client.write.as_raw_fd(), false)?;
|
||||
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
@ -192,6 +205,12 @@ impl Client {
|
||||
format!("{},{}", self.read.as_raw_fd(), self.write.as_raw_fd())
|
||||
}
|
||||
|
||||
pub fn available(&self) -> io::Result<usize> {
|
||||
let mut len = MaybeUninit::<c_int>::uninit();
|
||||
cvt(unsafe { libc::ioctl(self.read.as_raw_fd(), libc::FIONREAD, len.as_mut_ptr()) })?;
|
||||
Ok(unsafe { len.assume_init() } as usize)
|
||||
}
|
||||
|
||||
pub fn configure(&self, cmd: &mut Command) {
|
||||
// Here we basically just want to say that in the child process
|
||||
// we'll configure the read/write file descriptors to *not* be
|
||||
@ -322,6 +341,16 @@ fn set_cloexec(fd: c_int, set: bool) -> io::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
fn set_nonblocking(fd: c_int, set: bool) -> io::Result<()> {
|
||||
let status_flag = if set { libc::O_NONBLOCK } else { 0 };
|
||||
|
||||
unsafe {
|
||||
cvt(libc::fcntl(fd, libc::F_SETFL, status_flag))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cvt(t: c_int) -> io::Result<c_int> {
|
||||
if t == -1 {
|
||||
Err(io::Error::last_os_error())
|
||||
|
5
third_party/rust/jobserver/src/wasm.rs
vendored
5
third_party/rust/jobserver/src/wasm.rs
vendored
@ -59,6 +59,11 @@ impl Client {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn available(&self) -> io::Result<usize> {
|
||||
let lock = self.inner.count.lock().unwrap_or_else(|e| e.into_inner());
|
||||
Ok(*lock)
|
||||
}
|
||||
|
||||
pub fn configure(&self, _cmd: &mut Command) {
|
||||
unreachable!();
|
||||
}
|
||||
|
20
third_party/rust/jobserver/src/windows.rs
vendored
20
third_party/rust/jobserver/src/windows.rs
vendored
@ -170,6 +170,26 @@ impl Client {
|
||||
self.name.clone()
|
||||
}
|
||||
|
||||
pub fn available(&self) -> io::Result<usize> {
|
||||
// Can't read value of a semaphore on Windows, so
|
||||
// try to acquire without sleeping, since we can find out the
|
||||
// old value on release. If acquisiton fails, then available is 0.
|
||||
unsafe {
|
||||
let r = WaitForSingleObject(self.sem.0, 0);
|
||||
if r != WAIT_OBJECT_0 {
|
||||
Ok(0)
|
||||
} else {
|
||||
let mut prev: LONG = 0;
|
||||
let r = ReleaseSemaphore(self.sem.0, 1, &mut prev);
|
||||
if r != 0 {
|
||||
Ok(prev as usize + 1)
|
||||
} else {
|
||||
Err(io::Error::last_os_error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn configure(&self, _cmd: &mut Command) {
|
||||
// nothing to do here, we gave the name of our semaphore to the
|
||||
// child above
|
||||
|
3
third_party/rust/jobserver/tests/client.rs
vendored
3
third_party/rust/jobserver/tests/client.rs
vendored
@ -10,7 +10,6 @@ use std::thread;
|
||||
use futures::future::{self, Future};
|
||||
use futures::stream::{self, Stream};
|
||||
use jobserver::Client;
|
||||
use tempdir::TempDir;
|
||||
use tokio_core::reactor::Core;
|
||||
use tokio_process::CommandExt;
|
||||
|
||||
@ -128,7 +127,7 @@ fn main() {
|
||||
None => true,
|
||||
})
|
||||
.map(|test| {
|
||||
let td = t!(TempDir::new("foo"));
|
||||
let td = t!(tempfile::tempdir());
|
||||
let makefile = format!(
|
||||
"\
|
||||
all: export TEST_TO_RUN={}
|
||||
|
@ -5,7 +5,6 @@ use std::net::{TcpListener, TcpStream};
|
||||
use std::process::Command;
|
||||
|
||||
use jobserver::Client;
|
||||
use tempdir::TempDir;
|
||||
|
||||
macro_rules! t {
|
||||
($e:expr) => {
|
||||
@ -37,7 +36,7 @@ fn main() {
|
||||
}
|
||||
|
||||
let c = t!(Client::new(1));
|
||||
let td = TempDir::new("foo").unwrap();
|
||||
let td = tempfile::tempdir().unwrap();
|
||||
|
||||
let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string());
|
||||
|
||||
|
29
third_party/rust/jobserver/tests/server.rs
vendored
29
third_party/rust/jobserver/tests/server.rs
vendored
@ -8,7 +8,6 @@ use std::sync::Arc;
|
||||
use std::thread;
|
||||
|
||||
use jobserver::Client;
|
||||
use tempdir::TempDir;
|
||||
|
||||
macro_rules! t {
|
||||
($e:expr) => {
|
||||
@ -34,6 +33,30 @@ fn server_multiple() {
|
||||
drop((a, b));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn server_available() {
|
||||
let c = t!(Client::new(10));
|
||||
assert_eq!(c.available().unwrap(), 10);
|
||||
let a = c.acquire().unwrap();
|
||||
assert_eq!(c.available().unwrap(), 9);
|
||||
drop(a);
|
||||
assert_eq!(c.available().unwrap(), 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn server_none_available() {
|
||||
let c = t!(Client::new(2));
|
||||
assert_eq!(c.available().unwrap(), 2);
|
||||
let a = c.acquire().unwrap();
|
||||
assert_eq!(c.available().unwrap(), 1);
|
||||
let b = c.acquire().unwrap();
|
||||
assert_eq!(c.available().unwrap(), 0);
|
||||
drop(a);
|
||||
assert_eq!(c.available().unwrap(), 1);
|
||||
drop(b);
|
||||
assert_eq!(c.available().unwrap(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn server_blocks() {
|
||||
let c = t!(Client::new(1));
|
||||
@ -56,7 +79,7 @@ fn server_blocks() {
|
||||
#[test]
|
||||
fn make_as_a_single_thread_client() {
|
||||
let c = t!(Client::new(1));
|
||||
let td = TempDir::new("foo").unwrap();
|
||||
let td = tempfile::tempdir().unwrap();
|
||||
|
||||
let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string());
|
||||
let mut cmd = Command::new(prog);
|
||||
@ -110,7 +133,7 @@ foo
|
||||
#[test]
|
||||
fn make_as_a_multi_thread_client() {
|
||||
let c = t!(Client::new(1));
|
||||
let td = TempDir::new("foo").unwrap();
|
||||
let td = tempfile::tempdir().unwrap();
|
||||
|
||||
let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string());
|
||||
let mut cmd = Command::new(prog);
|
||||
|
Loading…
x
Reference in New Issue
Block a user