Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions kernel/crates/smoltcp/src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,17 @@ impl<'a> Socket<'a> {
self.tx_buffer.len()
}

/// Total unsent bytes if the peer window allows any new payload.
pub fn unsent_bytes_if_window_open(&self) -> usize {
let end = self.local_seq_no + self.tx_buffer.len();
let next = self.send_sequence_end();
if next < end && next < self.local_seq_no + self.remote_win_len {
end - next
} else {
0
}
}

/// Return the amount of octets queued in the receive buffer. This value can be larger than
/// the slice read by the next `recv` or `peek` call because it includes all queued octets,
/// and not only the octets that may be returned as a contiguous slice.
Expand Down
11 changes: 4 additions & 7 deletions kernel/src/net/socket/inet/stream/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ impl TcpSocket {
pub(crate) fn update_events(&self) -> bool {
// If cork was disabled or SHUT_WR was requested while there are still cork-buffered bytes,
// opportunistically flush them so the data does not become unreachable and FIN can be sent.
if !self
.cork_flush_in_progress
if (!self
.options
.tcp_cork
.load(core::sync::atomic::Ordering::Relaxed)
&& (!self
.options
.tcp_cork
.load(core::sync::atomic::Ordering::Relaxed)
|| self.is_send_shutdown())
|| self.is_send_shutdown())
&& !self.cork_buf.lock().is_empty()
{
let _ = self.flush_cork_buffer();
Expand Down
Loading
Loading