зеркало из https://github.com/mozilla/sccache.git
[commands::run_server_process]: fix race condition (#2077)
This commit is contained in:
Родитель
6f0d3c336c
Коммит
1539987a88
|
@ -89,6 +89,15 @@ fn run_server_process(startup_timeout: Option<Duration>) -> Result<ServerStartup
|
|||
let runtime = Runtime::new()?;
|
||||
let exe_path = env::current_exe()?;
|
||||
let workdir = exe_path.parent().expect("executable path has no parent?!");
|
||||
|
||||
// Spawn a blocking task to bind the Unix socket. Note that the socket
|
||||
// must be bound before spawning `_child` below to avoid a race between
|
||||
// the parent binding the socket and the child connecting to it.
|
||||
let listener = {
|
||||
let _guard = runtime.enter();
|
||||
tokio::net::UnixListener::bind(&socket_path)?
|
||||
};
|
||||
|
||||
let _child = process::Command::new(&exe_path)
|
||||
.current_dir(workdir)
|
||||
.env("SCCACHE_START_SERVER", "1")
|
||||
|
@ -97,7 +106,6 @@ fn run_server_process(startup_timeout: Option<Duration>) -> Result<ServerStartup
|
|||
.spawn()?;
|
||||
|
||||
let startup = async move {
|
||||
let listener = tokio::net::UnixListener::bind(&socket_path)?;
|
||||
let (socket, _) = listener.accept().await?;
|
||||
|
||||
read_server_startup_status(socket).await
|
||||
|
|
Загрузка…
Ссылка в новой задаче