@@ -5,8 +5,10 @@ extern crate hamcrest;
5
5
6
6
use std:: fs:: { self , File } ;
7
7
use std:: io:: prelude:: * ;
8
- use std:: net:: TcpListener ;
8
+ use std:: net:: { TcpListener , TcpStream } ;
9
9
use std:: path:: Path ;
10
+ use std:: sync:: Arc ;
11
+ use std:: sync:: atomic:: { AtomicBool , Ordering } ;
10
12
use std:: thread;
11
13
12
14
use cargo:: util:: process;
@@ -2198,12 +2200,13 @@ fn failed_submodule_checkout() {
2198
2200
2199
2201
let listener = TcpListener :: bind ( "127.0.0.1:0" ) . unwrap ( ) ;
2200
2202
let addr = listener. local_addr ( ) . unwrap ( ) ;
2203
+ let done = Arc :: new ( AtomicBool :: new ( false ) ) ;
2204
+ let done2 = done. clone ( ) ;
2201
2205
2202
2206
let t = thread:: spawn ( move || {
2203
- let a = listener. accept ( ) . unwrap ( ) ;
2204
- drop ( a) ;
2205
- let a = listener. accept ( ) . unwrap ( ) ;
2206
- drop ( a) ;
2207
+ while !done2. load ( Ordering :: SeqCst ) {
2208
+ drop ( listener. accept ( ) ) ;
2209
+ }
2207
2210
} ) ;
2208
2211
2209
2212
let repo = git2:: Repository :: open ( & git_project2. root ( ) ) . unwrap ( ) ;
@@ -2248,5 +2251,7 @@ fn failed_submodule_checkout() {
2248
2251
. with_stderr_contains ( " failed to update submodule `src`" )
2249
2252
. with_stderr_contains ( " failed to update submodule `bar`" ) ) ;
2250
2253
2254
+ done. store ( true , Ordering :: SeqCst ) ;
2255
+ drop ( TcpStream :: connect ( & addr) ) ;
2251
2256
t. join ( ) . unwrap ( ) ;
2252
2257
}
0 commit comments