Skip to content

Commit 1ce4c98

Browse files
committed
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
2 parents 0193a56 + 0d38cae commit 1ce4c98

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libstd/io/net/udp.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,12 @@ mod test {
557557
let addr1 = next_test_ip4();
558558
let addr2 = next_test_ip4();
559559
let mut a = UdpSocket::bind(addr1).unwrap();
560+
let a2 = UdpSocket::bind(addr2).unwrap();
560561

561562
let (tx, rx) = channel();
562563
let (tx2, rx2) = channel();
563564
spawn(move|| {
564-
let mut a = UdpSocket::bind(addr2).unwrap();
565+
let mut a = a2;
565566
assert_eq!(a.recv_from(&mut [0]), Ok((1, addr1)));
566567
assert_eq!(a.send_to(&[0], addr1), Ok(()));
567568
rx.recv();

0 commit comments

Comments
 (0)