Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tcp): only reset remote_last_ts if some data is enqueued #917

Merged
merged 1 commit into from
Apr 8, 2024
Merged
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
18 changes: 9 additions & 9 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,21 +1123,21 @@ impl<'a> Socket<'a> {
return Err(SendError::InvalidState);
}

// The connection might have been idle for a long time, and so remote_last_ts
// would be far in the past. Unless we clear it here, we'll abort the connection
// down over in dispatch() by erroneously detecting it as timed out.
if self.tx_buffer.is_empty() {
self.remote_last_ts = None
}

let _old_length = self.tx_buffer.len();
let old_length = self.tx_buffer.len();
let (size, result) = f(&mut self.tx_buffer);
if size > 0 {
// The connection might have been idle for a long time, and so remote_last_ts
// would be far in the past. Unless we clear it here, we'll abort the connection
// down over in dispatch() by erroneously detecting it as timed out.
if old_length == 0 {
self.remote_last_ts = None
}

#[cfg(any(test, feature = "verbose"))]
tcp_trace!(
"tx buffer: enqueueing {} octets (now {})",
size,
_old_length + size
old_length + size
);
}
Ok(result)
Expand Down
Loading