Skip to content

Commit 06becd7

Browse files
committed
---
yaml --- r: 130138 b: refs/heads/master c: 0e7e107 h: refs/heads/master v: v3
1 parent ac4b3a3 commit 06becd7

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b090905b1750983bf41094e7a940a333324e3e10
2+
refs/heads/master: 0e7e107ad69cc6f7facdc9401456a333361b5555
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67b97ab6d2b7de9b69fd97dc171fcf8feec932ff
55
refs/heads/try: 28d5878c1f0465c11c8e7a3085008b0c592d48d0

trunk/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)