Skip to content

Commit 086b297

Browse files
author
Jakub Bukaj
committed
rollup merge of #18985: alexcrichton/issue-18900
2 parents 94c8bb4 + 3e0368e commit 086b297

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/libstd/io/net/tcp.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -661,23 +661,22 @@ mod test {
661661
let addr = next_test_ip4();
662662
let mut acceptor = TcpListener::bind(addr).listen();
663663

664+
let (tx, rx) = channel();
664665
spawn(proc() {
665-
let _stream = TcpStream::connect(addr);
666-
// Close
666+
drop(TcpStream::connect(addr));
667+
tx.send(());
667668
});
668669

669670
let mut stream = acceptor.accept();
671+
rx.recv();
670672
let buf = [0];
671-
loop {
672-
match stream.write(buf) {
673-
Ok(..) => {}
674-
Err(e) => {
675-
assert!(e.kind == ConnectionReset ||
676-
e.kind == BrokenPipe ||
677-
e.kind == ConnectionAborted,
678-
"unknown error: {}", e);
679-
break;
680-
}
673+
match stream.write(buf) {
674+
Ok(..) => {}
675+
Err(e) => {
676+
assert!(e.kind == ConnectionReset ||
677+
e.kind == BrokenPipe ||
678+
e.kind == ConnectionAborted,
679+
"unknown error: {}", e);
681680
}
682681
}
683682
}
@@ -687,23 +686,22 @@ mod test {
687686
let addr = next_test_ip6();
688687
let mut acceptor = TcpListener::bind(addr).listen();
689688

689+
let (tx, rx) = channel();
690690
spawn(proc() {
691-
let _stream = TcpStream::connect(addr);
692-
// Close
691+
drop(TcpStream::connect(addr));
692+
tx.send(());
693693
});
694694

695695
let mut stream = acceptor.accept();
696+
rx.recv();
696697
let buf = [0];
697-
loop {
698-
match stream.write(buf) {
699-
Ok(..) => {}
700-
Err(e) => {
701-
assert!(e.kind == ConnectionReset ||
702-
e.kind == BrokenPipe ||
703-
e.kind == ConnectionAborted,
704-
"unknown error: {}", e);
705-
break;
706-
}
698+
match stream.write(buf) {
699+
Ok(..) => {}
700+
Err(e) => {
701+
assert!(e.kind == ConnectionReset ||
702+
e.kind == BrokenPipe ||
703+
e.kind == ConnectionAborted,
704+
"unknown error: {}", e);
707705
}
708706
}
709707
}

0 commit comments

Comments
 (0)