Skip to content

Commit f4aafd6

Browse files
committed
auto merge of #16916 : alexcrichton/rust/tcp-accept-stress-again-oh-my, r=brson
The tcp-accept-stress, despite the previous modifications, is still deadlocking on the osx buildbots. When building/testing/running repeatedly locally, it was discovered that the test would often fail with TcpStream::connect returning the error `address not available`. This test opens up quite a large number of sockets, and it looks like by default osx isn't the speediest at recycling those sockets for further use. The test has been modified (and verified) to not deadlock in this error case, and the test is not just officially ignored on OSX (with no FIXME). I believe that we'll get good coverage of the relevant code on the linux builders, so this isn't so much of a loss. At the same time I turned down the stress parameters to hopefully lighten the socket load on other platforms.
2 parents dfbd466 + 79f51c1 commit f4aafd6

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/test/run-pass/tcp-accept-stress.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-macos osx really doesn't like cycling through large numbers of
12+
// sockets as calls to connect() will start returning EADDRNOTAVAIL
13+
// quite quickly and it takes a few seconds for the sockets to get
14+
// recycled.
15+
1116
#![feature(phase)]
1217

1318
#[phase(plugin)]
@@ -20,7 +25,7 @@ use std::task::TaskBuilder;
2025
use native::NativeTaskBuilder;
2126

2227
static N: uint = 8;
23-
static M: uint = 100;
28+
static M: uint = 20;
2429

2530
green_start!(main)
2631

@@ -40,11 +45,12 @@ fn test() {
4045
let mut a = l.listen().unwrap();
4146
let cnt = Arc::new(atomic::AtomicUint::new(0));
4247

43-
let (tx, rx) = channel();
48+
let (srv_tx, srv_rx) = channel();
49+
let (cli_tx, cli_rx) = channel();
4450
for _ in range(0, N) {
4551
let a = a.clone();
4652
let cnt = cnt.clone();
47-
let tx = tx.clone();
53+
let srv_tx = srv_tx.clone();
4854
spawn(proc() {
4955
let mut a = a;
5056
loop {
@@ -58,33 +64,36 @@ fn test() {
5864
Err(e) => fail!("{}", e),
5965
}
6066
}
61-
tx.send(());
67+
srv_tx.send(());
6268
});
6369
}
6470

6571
for _ in range(0, N) {
66-
let tx = tx.clone();
72+
let cli_tx = cli_tx.clone();
6773
spawn(proc() {
6874
for _ in range(0, M) {
6975
let _s = TcpStream::connect(addr.ip.to_string().as_slice(),
7076
addr.port).unwrap();
7177
}
72-
tx.send(());
78+
cli_tx.send(());
7379
});
7480
}
75-
drop(tx);
81+
drop((cli_tx, srv_tx));
7682

7783
// wait for senders
78-
assert_eq!(rx.iter().take(N).count(), N);
84+
if cli_rx.iter().take(N).count() != N {
85+
a.close_accept().unwrap();
86+
fail!("clients failed");
87+
}
7988

8089
// wait for one acceptor to die
81-
let _ = rx.recv();
90+
let _ = srv_rx.recv();
8291

8392
// Notify other receivers should die
8493
a.close_accept().unwrap();
8594

8695
// wait for receivers
87-
assert_eq!(rx.iter().take(N - 1).count(), N - 1);
96+
assert_eq!(srv_rx.iter().take(N - 1).count(), N - 1);
8897

8998
// Everything should have been accepted.
9099
assert_eq!(cnt.load(atomic::SeqCst), N * M);

0 commit comments

Comments
 (0)