about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-12-17 08:34:34 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-12-17 11:50:27 -0800
commitde0570de21007e1174f72e2af69fa836243658ca (patch)
treeaff382527552c2edfad4585e2e0bbdf31e830ce5
parent75a84f9a3ebef4565309a9e66cc544ab422edc14 (diff)
parent0d38cae0b9e23f1557ce96fd7a9677f1040fab54 (diff)
downloadrust-de0570de21007e1174f72e2af69fa836243658ca.tar.gz
rust-de0570de21007e1174f72e2af69fa836243658ca.zip
rollup merge of #19859: alexcrichton/flaky-test
This test would read with a timeout and then send a UDP message, expecting the
message to be received. The receiving port, however, was bound in the child
thread so it could be the case that the timeout and send happens before the
child thread runs. To remedy this we just bind the port before the child thread
runs, moving it into the child later on.

cc #19120
-rw-r--r--src/libstd/io/net/udp.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs
index 78951b8dae2..ce7e5ca5f5e 100644
--- a/src/libstd/io/net/udp.rs
+++ b/src/libstd/io/net/udp.rs
@@ -557,11 +557,12 @@ mod test {
         let addr1 = next_test_ip4();
         let addr2 = next_test_ip4();
         let mut a = UdpSocket::bind(addr1).unwrap();
+        let a2 = UdpSocket::bind(addr2).unwrap();
 
         let (tx, rx) = channel();
         let (tx2, rx2) = channel();
         spawn(move|| {
-            let mut a = UdpSocket::bind(addr2).unwrap();
+            let mut a = a2;
             assert_eq!(a.recv_from(&mut [0]), Ok((1, addr1)));
             assert_eq!(a.send_to(&[0], addr1), Ok(()));
             rx.recv();