File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,15 @@ fn run_server_process(startup_timeout: Option<Duration>) -> Result<ServerStartup
89
89
let runtime = Runtime :: new ( ) ?;
90
90
let exe_path = env:: current_exe ( ) ?;
91
91
let workdir = exe_path. parent ( ) . expect ( "executable path has no parent?!" ) ;
92
+
93
+ // Spawn a blocking task to bind the Unix socket. Note that the socket
94
+ // must be bound before spawning `_child` below to avoid a race between
95
+ // the parent binding the socket and the child connecting to it.
96
+ let listener = {
97
+ let _guard = runtime. enter ( ) ;
98
+ tokio:: net:: UnixListener :: bind ( & socket_path) ?
99
+ } ;
100
+
92
101
let _child = process:: Command :: new ( & exe_path)
93
102
. current_dir ( workdir)
94
103
. env ( "SCCACHE_START_SERVER" , "1" )
@@ -97,7 +106,6 @@ fn run_server_process(startup_timeout: Option<Duration>) -> Result<ServerStartup
97
106
. spawn ( ) ?;
98
107
99
108
let startup = async move {
100
- let listener = tokio:: net:: UnixListener :: bind ( & socket_path) ?;
101
109
let ( socket, _) = listener. accept ( ) . await ?;
102
110
103
111
read_server_startup_status ( socket) . await
You can’t perform that action at this time.
0 commit comments