Skip to content

Commit 4dab80c

Browse files
committed
Simplify tcp::Socket::can_recv
This function does not actually care about the socket state, so there is no need to check it. The ability to immediately receive data only depends on there being something in the receive buffer.
1 parent 39cd44e commit 4dab80c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/socket/tcp.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ impl<'a> Socket<'a> {
11851185
// we still can receive indefinitely.
11861186
State::FinWait1 | State::FinWait2 => true,
11871187
// If we have something in the receive buffer, we can receive that.
1188-
_ if !self.rx_buffer.is_empty() => true,
1188+
_ if self.can_recv() => true,
11891189
_ => false,
11901190
}
11911191
}
@@ -1213,14 +1213,9 @@ impl<'a> Socket<'a> {
12131213
self.tx_buffer.capacity()
12141214
}
12151215

1216-
/// Check whether the receive half of the full-duplex connection buffer is open
1217-
/// (see [may_recv](#method.may_recv)), and the receive buffer is not empty.
1216+
/// Check whether the receive buffer is not empty.
12181217
#[inline]
12191218
pub fn can_recv(&self) -> bool {
1220-
if !self.may_recv() {
1221-
return false;
1222-
}
1223-
12241219
!self.rx_buffer.is_empty()
12251220
}
12261221

0 commit comments

Comments
 (0)