Skip to content

Commit c7687f7

Browse files
thomaseizingerdjc
authored andcommitted
refactor(quinn-udp): use match blocks in recv
For consistency with the `send` functions, we perform the error handling with `match` blocks instead of `if`.
1 parent 3e81eb0 commit c7687f7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

quinn-udp/src/unix.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,11 @@ fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) ->
491491
}
492492

493493
let e = io::Error::last_os_error();
494-
if e.kind() == io::ErrorKind::Interrupted {
495-
continue;
494+
match e.kind() {
495+
// Retry receiving
496+
io::ErrorKind::Interrupted => continue,
497+
_ => return Err(e),
496498
}
497-
498-
return Err(e);
499499
};
500500
for i in 0..(msg_count as usize) {
501501
meta[i] = decode_recv(&names[i], &hdrs[i].msg_hdr, hdrs[i].msg_len as usize);
@@ -520,11 +520,11 @@ fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) ->
520520
}
521521

522522
let e = io::Error::last_os_error();
523-
if e.kind() == io::ErrorKind::Interrupted {
524-
continue;
523+
match e.kind() {
524+
// Retry receiving
525+
io::ErrorKind::Interrupted => continue,
526+
_ => return Err(e),
525527
}
526-
527-
return Err(e);
528528
};
529529
for i in 0..(msg_count as usize) {
530530
meta[i] = decode_recv(&names[i], &hdrs[i], hdrs[i].msg_datalen as usize);
@@ -550,11 +550,11 @@ fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) ->
550550
}
551551

552552
let e = io::Error::last_os_error();
553-
if e.kind() == io::ErrorKind::Interrupted {
554-
continue;
553+
match e.kind() {
554+
// Retry receiving
555+
io::ErrorKind::Interrupted => continue,
556+
_ => return Err(e),
555557
}
556-
557-
return Err(e);
558558
};
559559
meta[0] = decode_recv(&name, &hdr, n as usize);
560560
Ok(1)

0 commit comments

Comments
 (0)