auto merge of #12054 : alexcrichton/rust/less-flaky-udp, r=brson
I have a hunch this just deadlocked the windows bots. Due to UDP being a lossy protocol, I don't think we can guarantee that the server can receive both packets, so just listen for one of them.
This commit is contained in:
commit
8dc06802b2
1 changed files with 10 additions and 7 deletions
|
@ -335,17 +335,18 @@ mod test {
|
||||||
let sock2 = UdpSocket::bind(addr2).unwrap();
|
let sock2 = UdpSocket::bind(addr2).unwrap();
|
||||||
|
|
||||||
let (p, c) = SharedChan::new();
|
let (p, c) = SharedChan::new();
|
||||||
|
let (serv_port, serv_chan) = Chan::new();
|
||||||
|
|
||||||
spawn(proc() {
|
spawn(proc() {
|
||||||
let mut sock2 = sock2;
|
let mut sock2 = sock2;
|
||||||
let mut buf = [0, 1];
|
let mut buf = [0, 1];
|
||||||
|
|
||||||
for _ in p.iter() {
|
p.recv();
|
||||||
match sock2.recvfrom(buf) {
|
match sock2.recvfrom(buf) {
|
||||||
Ok(..) => {}
|
Ok(..) => {}
|
||||||
Err(e) => fail!("failed receive: {}", e),
|
Err(e) => fail!("failed receive: {}", e),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
serv_chan.send(());
|
||||||
});
|
});
|
||||||
|
|
||||||
let sock3 = sock1.clone();
|
let sock3 = sock1.clone();
|
||||||
|
@ -355,16 +356,18 @@ mod test {
|
||||||
spawn(proc() {
|
spawn(proc() {
|
||||||
let mut sock3 = sock3;
|
let mut sock3 = sock3;
|
||||||
match sock3.sendto([1], addr2) {
|
match sock3.sendto([1], addr2) {
|
||||||
Ok(..) => c2.send(()),
|
Ok(..) => { let _ = c2.try_send(()); }
|
||||||
Err(..) => {}
|
Err(..) => {}
|
||||||
}
|
}
|
||||||
done.send(());
|
done.send(());
|
||||||
});
|
});
|
||||||
match sock1.sendto([2], addr2) {
|
match sock1.sendto([2], addr2) {
|
||||||
Ok(..) => c.send(()),
|
Ok(..) => { let _ = c.try_send(()); }
|
||||||
Err(..) => {}
|
Err(..) => {}
|
||||||
}
|
}
|
||||||
|
drop(c);
|
||||||
|
|
||||||
p.recv();
|
p.recv();
|
||||||
|
serv_port.recv();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue