about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-09-02 19:16:07 +0000
committerbors <bors@rust-lang.org>2014-09-02 19:16:07 +0000
commitf4aafd67137d0ea01a317311ca804f73543bc909 (patch)
tree0b30fd05520efcdf9b5991e3d7a0e05991ec3ae3
parentdfbd4669cd0ce6298b5cee7d4b5e1585d8228daa (diff)
parent79f51c1d31a4010c91234768765a4ebb44d8e6ed (diff)
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.
-rw-r--r--src/test/run-pass/tcp-accept-stress.rs29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/test/run-pass/tcp-accept-stress.rs b/src/test/run-pass/tcp-accept-stress.rs
index 372f6a473b2..1d69568e2b8 100644
--- a/src/test/run-pass/tcp-accept-stress.rs
+++ b/src/test/run-pass/tcp-accept-stress.rs
@@ -8,6 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// ignore-macos osx really doesn't like cycling through large numbers of
+//              sockets as calls to connect() will start returning EADDRNOTAVAIL
+//              quite quickly and it takes a few seconds for the sockets to get
+//              recycled.
+
 #![feature(phase)]
 
 #[phase(plugin)]
@@ -20,7 +25,7 @@ use std::task::TaskBuilder;
 use native::NativeTaskBuilder;
 
 static N: uint = 8;
-static M: uint = 100;
+static M: uint = 20;
 
 green_start!(main)
 
@@ -40,11 +45,12 @@ fn test() {
     let mut a = l.listen().unwrap();
     let cnt = Arc::new(atomic::AtomicUint::new(0));
 
-    let (tx, rx) = channel();
+    let (srv_tx, srv_rx) = channel();
+    let (cli_tx, cli_rx) = channel();
     for _ in range(0, N) {
         let a = a.clone();
         let cnt = cnt.clone();
-        let tx = tx.clone();
+        let srv_tx = srv_tx.clone();
         spawn(proc() {
             let mut a = a;
             loop {
@@ -58,33 +64,36 @@ fn test() {
                     Err(e) => fail!("{}", e),
                 }
             }
-            tx.send(());
+            srv_tx.send(());
         });
     }
 
     for _ in range(0, N) {
-        let tx = tx.clone();
+        let cli_tx = cli_tx.clone();
         spawn(proc() {
             for _ in range(0, M) {
                 let _s = TcpStream::connect(addr.ip.to_string().as_slice(),
                                             addr.port).unwrap();
             }
-            tx.send(());
+            cli_tx.send(());
         });
     }
-    drop(tx);
+    drop((cli_tx, srv_tx));
 
     // wait for senders
-    assert_eq!(rx.iter().take(N).count(), N);
+    if cli_rx.iter().take(N).count() != N {
+        a.close_accept().unwrap();
+        fail!("clients failed");
+    }
 
     // wait for one acceptor to die
-    let _ = rx.recv();
+    let _ = srv_rx.recv();
 
     // Notify other receivers should die
     a.close_accept().unwrap();
 
     // wait for receivers
-    assert_eq!(rx.iter().take(N - 1).count(), N - 1);
+    assert_eq!(srv_rx.iter().take(N - 1).count(), N - 1);
 
     // Everything should have been accepted.
     assert_eq!(cnt.load(atomic::SeqCst), N * M);