Skip to content

Commit 7f197ff

Browse files
committed
---
yaml --- r: 154783 b: refs/heads/try2 c: 0e7e107 h: refs/heads/master i: 154781: f980352 154779: 4ab740f 154775: dc06efd 154767: a5f9440 154751: 9c4ebbf v: v3
1 parent 1b3fda6 commit 7f197ff

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b090905b1750983bf41094e7a940a333324e3e10
8+
refs/heads/try2: 0e7e107ad69cc6f7facdc9401456a333361b5555
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)